Closed
Description
scala> def ll() = { var counter = 0 ; LazyList.continually{println(counter); counter += 1; counter} }
ll: ()scala.collection.immutable.LazyList[Int]
scala> ll()(5)
0
res9: Int = 1
scala> ll().take(5).last
0
1
2
3
4
res10: Int = 5
reported by @paulp at https://twitter.com/contrarivariant/status/1030065587559362561
are there other methods that may have this problem?
related: #11083
/cc @NthPortal @szeiger @julienrf
methods to fix:
-
last
-
dropRight
-
takeRight
-
slice