Reputation: 3
Why can I compare an Int and a String in Scala with ==, like 1=="2"
, even when this Operator is not defined for a String in the API (http://www.scala-lang.org/api/2.11.8/index.html#scala.Int)?
Upvotes: 0
Views: 74
Reputation: 3530
Because it's defined in Any
: def ==(arg0: Any): Boolean
Test two objects for equality. The expression x == that is equivalent to if (x eq null) that eq null else x.equals(that).
Upvotes: 3