What is the difference between Nil and List() in Scala?

Scala FAQ: What is the difference between Nil and List() in Scala?

Short answer: There isn’t any difference, as shown in the Scala REPL:

scala> Nil == List()
res0: Boolean = true

It’s more “idiomatic Scala” Scala to use Nil rather than List(). For instance, I wrote code like this last night using Nil in a Scala match/case expression:

Syndicate content