Strings, Arrays, Iterables
brian.goetz at oracle.com
Mon Sep 3 10:46:59 PDT 2012
> I understand arrays will not get the benefits of iterables,that is to say,
> map/reduce/foreach, etc.
Yes and no. There will be static methods in Arrays to turn them into
So, while you are correct in that they will not magically appear as
instance methods on arrays, the functionality is all there, there's just
a little extra syntactic overhead.
> But I also think that it will be a great help for people like me to be able
> to use a String as a Iterable<Character>, mostly because of didactic
> reasons. It is nice and easy to test functional stuff using Strings. And it
> won't hurt anyone to be able to actually do functional processing of
Right. As you point out, if String were to be Iterable<X> (and there
can be only one X, due to erasure), what should it be? Should it be
characters? Code points? Something else (like words, as you suggest)?
What we've decided to do is expose new accessor methods on String:
This should do the job, except for that pesky matter of boxing. We're
working on some approaches there, stay tuned.
More information about the lambda-dev