[ 
https://issues.apache.org/jira/browse/GROOVY-10028?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Daniel Sun resolved GROOVY-10028.
---------------------------------
    Fix Version/s: 4.0.0-beta-1
       Resolution: Fixed

The proposed PR has been merged. Thanks!

> Add support for type conversion from Stream to array/collection/list/set
> ------------------------------------------------------------------------
>
>                 Key: GROOVY-10028
>                 URL: https://issues.apache.org/jira/browse/GROOVY-10028
>             Project: Groovy
>          Issue Type: Improvement
>          Components: groovy-jdk
>            Reporter: Eric Milles
>            Assignee: Eric Milles
>            Priority: Minor
>             Fix For: 4.0.0-beta-1
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> Consider the following:
> {code:groovy}
> void test(source) {
>   Number[] array = source
>   println array.class
>   println array
>   Collection coll = source
>   println coll.class
>   println coll
>   List list = source
>   println list.class
>   println list
>   Set set = source
>   println set.class
>   println set
> }
> test(new int[] {1,2,3})
> test(Arrays.asList(1,2,3))
> test(Arrays.stream(1,2,3))
> {code}
> Groovy supports automatic/implicit conversion from array to 
> array/collection/list/set.  And similarly for list to array or set (a list is 
> already a collection/iterable).  Can the type conversion logic be extended to 
> support {{java.util.stream.Stream}} as a source for array/collection/list/set 
> to eliminate the need for ".toArray()", ".toList()", ".toSet()" and 
> ".collect(...)" in common situations?



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to