Details
-
Improvement
-
Status: Closed
-
Minor
-
Resolution: Fixed
-
None
-
None
Description
Consider the following:
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))
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?