[
https://issues.apache.org/jira/browse/GROOVY-9545?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles updated GROOVY-9545:
--------------------------------
Issue Type: Improvement (was: Documentation)
> 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
>
> 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)