[ 
https://issues.apache.org/jira/browse/GROOVY-10672?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17560683#comment-17560683
 ] 

Paul King edited comment on GROOVY-10672 at 6/30/22 12:27 PM:
--------------------------------------------------------------

Naming is always hard! :)

I was avoiding "from" since ranges have a "from" and "to" already but maybe 
that won't be a problem.

"withIndices" or "havingIndex" or "forIndices" work but are both a bit long, 
"window" could work but might seem strange when writing GUI code, "taking" 
distances a little from "take" but no-one will remember when to swap, "slice" 
could work but could mean one or more slices.


was (Author: paulk):
Naming is always hard! :)

I was avoiding "from" since ranges have a "from" and "to" already but maybe 
that won't be a problem.

"withIndices" or "havingIndex" work but are both a bit long, "window" could 
work but might seem strange when writing GUI code, "taking" distances a little 
from "take" but no-one will remember when to swap, "slice" could work but could 
mean one or more slices.

> 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)

Reply via email to