Method reference toString

Stephen Colebourne scolebourne at joda.org
Wed Dec 19 06:34:31 PST 2012


By "key" I mean this. Previously, I used:
 LocalDate date = parser.parse(LocalDate.class)
now I use
 LocalDate date = parser.parse(LocalDate::from)

I was hoping to have an error message referencing "LocalDate::from",
the toString form of the method ref.


By no identity, is the following guaranteed to be true?

public static Query<LocalDate> QUERY = LocalDate::from;
assert QUERY == QUERY

(I assume so...)

Stephen



On 19 December 2012 14:21, Brian Goetz <brian.goetz at oracle.com> wrote:
> No, the EG has not decided on that to date.
>
> What do you mean by key?  Remember that you can can't count on identity for
> lambdas/method refs, making them unsuitable as keys in Maps...
>
>
> On 12/19/2012 8:26 AM, Stephen Colebourne wrote:
>>
>> Has a decision been taken on the toString() of a method reference? And
>> I guess of lambdas more generally?
>>
>> In JSR-310 I'm starting to use method references as the key for
>> parsing (instead of a class reference), but I'd like to be able to use
>> the toString() to produce nice error messages as well.
>>
>> Stephen
>>
>


More information about the lambda-dev mailing list