You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@groovy.apache.org by "Eric Milles (Jira)" <ji...@apache.org> on 2021/04/10 15:26:00 UTC
[jira] [Created] (GROOVY-10028) Add support for type conversion
from Stream to array/collection/list/set
Eric Milles created GROOVY-10028:
------------------------------------
Summary: 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: Bug
Components: groovy-jdk
Reporter: Eric Milles
Assignee: Eric Milles
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. 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(...)"?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)