Strings, Arrays, Iterables
Pablo Grisafi
pablogrisafi1975 at gmail.com
Mon Sep 3 10:29:21 PDT 2012
I understand arrays will not get the benefits of iterables,that is to say,
map/reduce/foreach, etc.
So whenever we are dealing with old methods that return arrays we will need
to wrap them in iterators. No big deal.
I'm sure that is not very important to process String is production code
using functional approaches, since we managed to work with Strings without
map/reduce/foreach for years.
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
String's.
While I'd love to have String implements Iterable<Character>, since most of
the time I use Strings as list of Characters, I'm sure other people will
ask for Strings implements Iterable<Byte>, String implements Iterable<Word>
or whatever.
(I'm sure String implements Iterable<Character> will be used in 90% of
cases, but that's my experience)
But what I think is that at least we should have a method toCharList or
something like that, besides toCharArray
(I hope this was not brought before, discussed and discarded)
Pablo Grisafi
pablogrisafi1975 at gmail.com
More information about the lambda-dev
mailing list