If you read the actual words in that document, a different story emerges: For a reference to an instance method of an arbitrary object, the type to which the method belongs precedes the delimiter, and the invocation's receiver is the first parameter of the functional interface method:
Arrays.sort(names, String::compareToIgnoreCase); On Nov 3, 2012 10:54 AM, "clay" <[email protected]> wrote: > State of the Lambda #4 ( > http://cr.openjdk.java.net/~briangoetz/lambda/lambda-state-4.html) says > you can do: > > ClassName::staticMethod > or > instanceName::instanceMethod > > On Friday, November 2, 2012 5:50:37 PM UTC-5, Ricky Clarkson wrote: >> >> I can't confirm right now but I'm pretty sure I've done >> ClassName::methodName in my experiments with FunctionalJava and Java 8. >> Doesn't the State of the Lambda cover that too? >> On Nov 2, 2012 6:54 PM, "clay" <[email protected]> wrote: >> >>> AFAIK, >>> >>> You can't do ClassName::instanceMethod() >>> You have to do classInstance::instanceMethod(**) >>> >>> So, even if getAddressOption() was an instance method, you would have to >>> do onePersonInstance::**getAddressOption, and the method reference is >>> bound to that one instance which wouldn't fit with the example. >>> >>> On Friday, November 2, 2012 4:33:14 PM UTC-5, Ricky Clarkson wrote: >>>> >>>> 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 <[email protected]> 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::**address**Option).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/**b**log<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<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/**ms**g/javaposse/-/SBpf_wVxh0gJ<https://groups.google.com/d/msg/javaposse/-/SBpf_wVxh0gJ>. >>>> >>>> > >>>> > To post to this group, send email to [email protected]. >>>> > 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<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/-/mhPVSnOnsIYJ<https://groups.google.com/d/msg/javaposse/-/mhPVSnOnsIYJ> >>> . >>> To post to this group, send email to [email protected]. >>> 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 <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/-/yzc9RMhScTgJ. > 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.
