I noticed that Stream is deprecated in Scala 2.13 and they suggest using LazyList.
They also say "Use LazyList (which is fully lazy) instead of Stream (which has a lazy tail only)".
What does it exactly mean ? Why did they deprecate Stream ?
What's the difference between LazyList and Stream in Scala?
3.6k Views Asked by Michael At
2
There are 2 best solutions below
0
On
As per the blog post:
LazyList Is Preferred Over Stream
Stream is deprecated in favor of LazyList. As its name suggests, a LazyList is a linked list whose elements are lazily evaluated. An important semantic difference with Stream is that in LazyList both the head and the tail are lazy, whereas in Stream only the tail is lazy.
Also in the Stream documentation:
Deprecated (Since version 2.13.0)
Use LazyList (which is fully lazy) instead of Stream (which has a lazy tail only)
NthPortal, a contributor to
LazyList, states in Update and improve LazyList docs #7842jwvh states in related question
Scala 2.13 release notes state
immutable.LazyListreplacesimmutable.Stream.Streamhad different laziness behavior and is now deprecated. (#7558, #7000)