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 2020/05/17 07:29:00 UTC
[jira] [Resolved] (GROOVY-9545) DGM: add toArray(Class) extension
method for java.util.stream.Stream
[ https://issues.apache.org/jira/browse/GROOVY-9545?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Paul King resolved GROOVY-9545.
-------------------------------
Fix Version/s: 3.0.4
4.0.0-alpha-1
Resolution: Fixed
> 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
> Fix For: 4.0.0-alpha-1, 3.0.4
>
> Time Spent: 40m
> 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)