Equality is always a tricky one!

I guess they could solve that by disallowing explicit .equals calls.  As
Int <: Any rather than AnyRef (AnyRef is analogous to Object whereas Any is
the supertype of both direct and reference types) there's no obligation to
provide .equals that I can see.

2012/3/12 Cédric Beust ♔ <[email protected]>

> On Mon, Mar 12, 2012 at 4:28 PM, Ricky Clarkson <[email protected]>
>  wrote:
>
> Scala doesn't really have primitives, but doesn't allocate a wrapper
>> object for Ints unless it really needs to, and in Scala List[Int] works,
>> 5.toString works and if you do happen to use java.lang.Integer instead of
>> Int, its == actually does the right thing
>
>
> Yup but in doing so, Scala managed to break a few other things along the
> way:
>
> scala> 1==1.0
> res1: Boolean = true
>
> scala> 1.equals(1.0)
> res2: Boolean = false
>
> --
> Cédric
>
>
>
>
>
>  --
> You received this message because you are subscribed to the Google Groups
> "The 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.
>

-- 
You received this message because you are subscribed to the Google Groups "The 
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.

Reply via email to