What will be the result of comparing Lists using eq function?
val a = List(1, 2, 3)
val b = List(1, 2, 3)

a eq b
eq is defined the following way:
final def eq(that: AnyRef): Boolean
eq tests whether the argument (that) is a reference to the receiver object (this).
Since a and b point to different instances of list (even though they contain the same elements), the result is false.

Source: Scala Exercises: lists

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback