What will be the result of comparing empty lists (Nil)?
val a: List[String] = Nil
val b: List[Int] = Nil

a == Nil // 1
a eq Nil // 2

b == Nil // 3
b eq Nil // 4

a == b // 5
a eq b // 6
Explanation
Nil is defined as following:
case object Nil extends List[Nothing]
Nil lists are identical, even of different types.

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback
Keep exploring
Scala quizzes
Cosmo
Sign Up Now
or Subscribe for future quizzes