Scala: Nil vs List()
scala
Solution
scala> println (Nil == List())
true
scala> println (Nil eq List())
true
scala> println (Nil equals List())
true
scala> System.identityHashCode(Nil)
374527572
scala> System.identityHashCode(List())
374527572
Nil is more idiomatic and can be preferred in most cases. Questions?
Problem
In Scala, is there any difference at all between `Nil` and `List()`? If not, which one is more idiomatic Scala style? Both for creating new empty lists and pattern matching on empty lists.