With proper support it would be:

List<String> zips2 =
people.flatMap(Person::addressOption).flatMap(Address:zipOption);

That might take a stubborn person a couple of minutes to understand
but after that even the most determined anti-flatmapper will be able
to curse, rewrite, fire the writer of but ultimately understand code
like this without any real trouble.

On Fri, Nov 2, 2012 at 5:22 PM, Fabrizio Giudici
<[email protected]> wrote:
> On Fri, 02 Nov 2012 21:12:07 +0100, clay <[email protected]> wrote:
>
>> In hindsight, a simpler solution (with static import of custom toIterable
>> method) would be:
>>
>> final List<String> zips2 = new ArrayList<String>();
>> for (Person p : people) { for (Address a : toIterable(p.addressOption)) {
>> for (String z : toIterable(a.zipOption)) { zips2.add(z); } } }
>
>
> Honestly, I don't find it particularly readable.
>
>
>
> --
> Fabrizio Giudici - Java Architect @ Tidalwave s.a.s.
> "We make Java work. Everywhere."
> http://tidalwave.it/fabrizio/blog - [email protected]
>
> --
> You received this message because you are subscribed to the Google Groups
> "Java Posse" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/javaposse?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups "Java 
Posse" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to