You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Paul King (Jira)" <ji...@apache.org> on 2022/06/30 12:43:00 UTC

[jira] [Commented] (GROOVY-10672) Provide a stream 'from' DGM method taking an IntRange

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

Paul King commented on GROOVY-10672:
------------------------------------

I changed the PR to use 'from'. We'll see if anyone can think of something better in the meantime.

> Provide a stream 'from' 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:java}
> Stream<String> stream = ['foo','bar','baz'].stream()
> assert stream.from(0<..<2).map(String::toUpperCase).toList() == ['BAR']
> {code}
> This is similar to the recently added {{getAt}} but keeps the stream nature.
> {code:java}
> assert stream[0<..<2].collect(String::toUpperCase) == ['BAR']
> {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)