Iterable::forEach not returning Iterable
Tomasz Kowalczewski
tomasz.kowalczewski at gmail.com
Thu May 17 03:33:59 PDT 2012
Hi,
I was trying out the new jdk8 build with lambdas and while doing some
simple towards-lamda-refactoring I stumbled on following use case:
List<File> files...
files.filter( File::isFile ).filter( ... ).map( ConfigurationFile::new );
I wanted to inject some debugging code inside this chain using forEach
and realized that it returns void and not Iterable. Its default
delegates to Iterables::forEach that returns Interable, so I guess it
is just a matter of deciding if forEach should seal the pipe or allow
more processing.
Based on my example I think there is a great value in changing the
return type from void as in my opinion it will be harder to debug and
step through such lambdanized code than through several (ugly)
for-each loops doing same work.
P.S.: Atttaching eclipse debugger to this code being run in a simple
main() instantly crashes the debugged JVM. But I guess debugging is
not yet supported anyway :)
--
Regards,
Tomasz Kowalczewski
More information about the lambda-dev
mailing list