Map.values returns an Iterable and the toSeq comes from TraversableOnce, which in turn calls toStream when you call toSeq.

This is a problem with the Seq abstraction or the Stream abstraction. However you want to look at it. List and Stream both implement Seq, but have different behaviour for certain operations. Imagine having an infinite Stream and you call .tail on it. it would never return.

I tend to not use Seq anymore, but use List everywhere. And Stream explicitly where I want Stream behaviour.

Related Query

More Query from same tag