Fun with method references
John Nilsson
john at milsson.nu
Thu Aug 5 06:54:10 PDT 2010
On Wed, Aug 4, 2010 at 11:33 PM, Brian Goetz <brian.goetz at oracle.com> wrote:
> Check this out -- this works with the latest prototype:
> Arrays.sortBy(foos, Foo#getA); // sort by JavaBean property A
I'm wondering if this kind of thing will increase the demand for
tuples in the language. So far it has been my experience that most
uses of classes such as Pair<A,B> is better served by actually naming
the attribute collection to something sensible. But with code like
this I can see how a simple tuple would simplify things.
So will
Arrays.sortBy(foos, tuple(Foo#getA,Foo#getB))
be good enough or would it be better with
Arrays.sortBy(foos, (Foo#getA,Foo#getB)) // Standard parenthesis tuple syntax
or
Arrays.sortBy(foos, Foo#getA x Foo#getB) // Product combinator operator
BR,
John
More information about the lambda-dev
mailing list