Lambdas and serialization

Alessio Stalla alessiostalla at gmail.com
Wed Nov 10 05:40:38 PST 2010


On Wed, Nov 10, 2010 at 2:16 PM, Llewellyn Falco <isidore at setgame.com> wrote:
> I just realized this is a mistake!
>
> Comparable will not work properly without the Equals method
> being overridden.
>
> Namely, if you have two object a, b you will get
> a.compareTo(b) == 0
> but
> a.equals(b) == false
>
> depending on your implementation this will fail!

Yes, but what's the point of implementing Comparable with a lambda?
Comparable models an extra capability of a class of objects with other
behaviour (say, Strings). In case of lambdas, the only behaviour is
the implementation of the target SAM, so if you implement a Comparable
with a lambda, you'll get an object with no capabilities except to
compare itself with other objects - not very useful.

Cheers,
Alessio


More information about the lambda-dev mailing list