[
https://issues.apache.org/jira/browse/GROOVY-10028?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Eric Milles updated GROOVY-10028:
---------------------------------
Description:
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(...)"?
was:
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(...)"?
> 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
> Priority: Minor
>
> 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(...)"?
--
This message was sent by Atlassian Jira
(v8.3.4#803005)