[
https://issues.apache.org/jira/browse/GROOVY-10672?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17560665#comment-17560665
]
Eric Milles commented on GROOVY-10672:
--------------------------------------
Essentially, this is just a shorthand for "skip" and "limit", correct?
Does it make more sense to name it "from" as in "stream.from(1..2).map(..."?
The other "take" extension methods accept a number of elements. They don't
provide a range-based interface. A new name gets us out of the debate about
adding "takeRight" and "takeWhile".
> Provide a stream 'take' DGM method taking an IntRange
> -----------------------------------------------------
>
> Key: GROOVY-10672
> URL: https://issues.apache.org/jira/browse/GROOVY-10672
> Project: Groovy
> Issue Type: Improvement
> Reporter: Paul King
> Assignee: Paul King
> Priority: Major
>
> {code}
> Stream<String> stream = ['foo','bar','baz'].stream()
> assert stream.take(0<..<2).map(String::toUpperCase).toList() == ['BAR']
> {code}
> This is similar to the recently added {{getAt}} but keeps the stream nature.
> {code}
> assert stream[0<..<2].collect(String::toUpperCase) == ['BAR']
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)