xushu
xushu

Reputation: 3

<Int> == <String>

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

Answers (1)

Hiura
Hiura

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

Related Questions