[
https://issues.apache.org/jira/browse/GROOVY-9545?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17108969#comment-17108969
]
Paul King commented on GROOVY-9545:
-----------------------------------
There shouldn't be an issue with closure literals. We sometimes add Class
variants when the SAM-type alternatives are more verbose, e.g.
{{optional.filter(Number)}} is shorthand for
{{optional.filter(Number::isInstance).map(Number::cast)}}.
I'll add some additional comments to the PR.
> DGM: add toArray(Class) extension method for java.util.stream.Stream
> --------------------------------------------------------------------
>
> Key: GROOVY-9545
> URL: https://issues.apache.org/jira/browse/GROOVY-9545
> Project: Groovy
> Issue Type: Improvement
> Components: groovy-jdk
> Affects Versions: 4.x, 3.0.3
> Reporter: Eric Milles
> Assignee: Eric Milles
> Priority: Minor
> Time Spent: 10m
> Remaining Estimate: 0h
>
> Proposal to add a new extension method for {{Stream}} that returns a typed
> array with minimal boilerplate (i.e. is somewhere in between {{toArray()}}
> and {{toArray(IntFunction)}}:
> {code:groovy}
> void test(List<String> list) {
> def array = list.stream().toArray() // returns Object[]
> array = list.stream().toArray(String) // returns String[] -- proposed
> extension
> array = list.stream().toArray(String[]::new) // returns String[] but
> requires "[]::new"
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.3.4#803005)