It's rare that you actually expose public fields in Java, so let's
assume addressOption and friends are methods, and then the method
reference syntax works fine.

Also, I said 'with proper support', regarding the returned collection
type. :)  But sure, adding a .into wouldn't be too bad.

On Fri, Nov 2, 2012 at 6:09 PM, clay <claytonw...@gmail.com> wrote:
> First, you can't use the :: method reference syntax with a variable.
>
> Secondly, the map and flatMap functions currently exist on the Stream
> interface and return a modified Stream. So you have to start with
> people.stream() and end with either a Stream instance or call
> .into(someCollection) to put them into a collection.
>
>
> On Friday, November 2, 2012 3:29:25 PM UTC-5, Ricky Clarkson wrote:
>>
>> 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
>> <fabrizio...@tidalwave.it> wrote:
>> > On Fri, 02 Nov 2012 21:12:07 +0100, clay <clayt...@gmail.com> 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 - fabrizio...@tidalwave.it
>> >
>> > --
>> > You received this message because you are subscribed to the Google
>> > Groups
>> > "Java Posse" group.
>> > To post to this group, send email to java...@googlegroups.com.
>> > To unsubscribe from this group, send email to
>> > javaposse+...@googlegroups.com.
>> > 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 view this discussion on the web visit
> https://groups.google.com/d/msg/javaposse/-/SBpf_wVxh0gJ.
>
> To post to this group, send email to javaposse@googlegroups.com.
> To unsubscribe from this group, send email to
> javaposse+unsubscr...@googlegroups.com.
> 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 javaposse@googlegroups.com.
To unsubscribe from this group, send email to 
javaposse+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/javaposse?hl=en.

Reply via email to