You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We need to update the import for newer versions of sbt, and it would be better to use Iterator instead of Stream to avoid the unnecessary memoization. The def is necessary to keep the iterator from starting until we want to see its values (by invoking next() directly or, as here, indirectly).
import jline.console.ConsoleReader
...
def it = Iterator.continually { reader.readLine("Prompt: ") }
val values = it.toList
The text was updated successfully, but these errors were encountered:
Thanks for this suggestion. Is this really a bug? I definitely agree it is better to use Iterator than Stream though. We also need to look at other examples using Stream, I think.
We should go through the entire tutorial and make sure it reflects our understanding of best current practices.
Agreed on both counts, of course. The dummy value, however, was only needed because things don't work the way they should when I/O gets involved. It must be related to the problems you discovered with scanLeft().
We also need to clean up the Monte Carlo examples, etc. Those work fine with Stream.continually() but we now know better to use Iterator.
Thanks for reporting these so we keep it on radar.
We need to update the import for newer versions of sbt, and it would be better to use
Iterator
instead ofStream
to avoid the unnecessary memoization. Thedef
is necessary to keep the iterator from starting until we want to see its values (by invokingnext()
directly or, as here, indirectly).The text was updated successfully, but these errors were encountered: