Eric Milles created GROOVY-9545:
-----------------------------------
Summary: 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: Documentation
Components: groovy-jdk
Affects Versions: 3.0.3, 4.x
Reporter: Eric Milles
Assignee: Eric Milles
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)