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

Eric Milles commented on GROOVY-9545:
-------------------------------------

Is it common to have Class and SAM-type alternatives for any method overloads?  
Is there any problem using closure literals when both options exist?

> 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: 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)

Reply via email to