Dick, your person/address/zip example perfectly illustrates the benefit of Option/Optional.
This is precisely the functionality that JDK8 is purposefully omitting and that we are debating. I've written some static function add-ons to support this optional flatMap type use case and ported your person/address/zip example. It looks like this: List<Person> people = ... // Omitting test data initialization final List<String> zips = new ArrayList<String>(); // Zip codes go here. // optionalMap is missing from JDK8. I wrote it and statically imported it. optionalMap(optionalMap(people.stream(), (p) -> p.addressOption), (a) -> a.zipOption).into(zips); If JDK8 had optionalMap built-in (or if I could add-on with C#-like extension methods), it would have the much more natural syntax: people.stream().optionalMap((p) -> p.addressOption).optionalMap((a) -> a.zipOption).into(zips); This offers pretty much all of the benefits of Option and is almost as elegant as your Scala example without any changes to the Java language. I've put a more complete code implementation + example in pastebin (separate class files are concatenated into a single pastebin paste): http://pastebin.com/id03sNvQ On Friday, November 2, 2012 11:19:54 AM UTC-5, Dick Wall wrote: > > val zips = for (person <- people; address <- person.addressOption; zip <- > address.zipOption) yield zip > > -- 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/-/cij_G0PamxYJ. 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.