ers@groovy.apache.org
Subject: Re: withIndex for streams
For interest, the code using Gatherers4J looks like:
assert names.stream()
.gather(Gatherers4j.filterIndexed {index, element -> index ==
3 }) // JDK24
.findFirst().get() == 'arne'
You can also use something
For interest, the code using Gatherers4J looks like:
assert names.stream()
.gather(Gatherers4j.filterIndexed {index, element -> index ==
3 }) // JDK24
.findFirst().get() == 'arne'
You can also use something like this using vanilla streams:
assert names.stream().skip(3).li
It might be worth exploring this. I'll note that gatherers (JDK 24)
provide a hook for adding such functionality in Java. Gatherers4j has
withIndex (though we'd likely implement it differently):
https://tginsberg.github.io/gatherers4j/gatherers/sequence-operations/withindex/
As well as a bunch of
Hi ,
I suggest that the withIndex method in DefaultGroovyMethods is overloaded with
an option to support streams as well
Given
names = ['per', 'karin', 'tage', 'arne', 'sixten', 'ulrik']
I can find the 4:th element with
println names[3]
or if I only have an iterator with
println names.iterato