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
Explanation
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

Следи за CodeGalaxy

Мобильное приложение Beta

Get it on Google Play
Обратная Связь
Продолжайте изучать
тесты по Scala
Cosmo
Зарегистрируйся сейчас
или Подпишись на будущие тесты