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

ASF GitHub Bot commented on GROOVY-11146:
-----------------------------------------

sonatype-lift[bot] commented on PR #1926:
URL: https://github.com/apache/groovy/pull/1926#issuecomment-1663242051

   ## Sonatype Lift is retiring
   Sonatype Lift will be retiring on <b>Sep 12, 2023</b>, with its analysis 
stopping on Aug 12, 2023. We understand that this news may come as a 
disappointment, and Sonatype is committed to helping you transition off it 
seamlessly. If you’d like to retain your data, please export your issues from 
the web console.
   We are extremely grateful and thank you for your support over the years.
   
   <b>[📖 Read about the impacts and 
timeline](https://www.sonatype.com/lift-retirement)</b>




> Consider supporting flattening of Optionals in flatten/collectMany
> ------------------------------------------------------------------
>
>                 Key: GROOVY-11146
>                 URL: https://issues.apache.org/jira/browse/GROOVY-11146
>             Project: Groovy
>          Issue Type: Improvement
>            Reporter: Paul King
>            Assignee: Paul King
>            Priority: Major
>
> The functional idiom of map/collect then flatten is so common that we 
> normally have a shorthand for combining them: flatMap, bind, collectMany.
> We have that for streams (piggybacking on Java) and collections but not 
> optionals.
> {code}
> var items = ["1", "2", "foo", "3", "bar"]
> var toInt1 = s -> s.number ? Stream.of(s.toInteger()) : Stream.empty()
> println items.stream().flatMap(toInt1).toList()
> var toInt2 = s -> s.number ? [s.toInteger()] : []
> println items.collectMany(toInt2)
> var toInt3 = s -> s.number ? Optional.of(s.toInteger()) : Optional.empty()
> println items.collect(toInt3).flatten{ it -> it.orElse([]) }
> println items.collect(toInt3).findResults{ it -> it.orElse(null) }
> println items.collect(toInt3).grep()*.get()
> {code}
> This issue will explore options for adding that.



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

Reply via email to