Scala reference equality
How do you test reference equality in Scala?
val x = new Obj
val y = x
x.referenceEquals(y) // evaluates to true
Solution 1:
The function you are looking for is eq
, which is a member of AnyRef:
val x = new Obj
val y = x
x eq y // evaluates to true
x ne y // evaluates to false