1

Experimenting with scalaz.NonEmptyList, I tried:

scala> import scalaz.NonEmptyList
import scalaz.NonEmptyList

scala> NonEmptyList("5", Nil)
res0: scalaz.NonEmptyList[java.io.Serializable] = NonEmptyList(5, List())

I mistakenly thought that List was the second argument to NonEmptyList#apply (it's actually varargs).

But, why does java.io.Serializable show up as the type?

1 Answer 1

3

You've constructed a list with two items, a String and a Nil. So the type of that list is NonEmptyList[A], where A is the lowest common supertype of both String and Nil, which is the type Serializable. Btw: the same thing happens with scala's normal List: List("5",Nil)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.