Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// pseudo-Scala with nonexistent "yield" in while
val generator =
while(true) {
val in = readLine()
if (in == null)
break
yield in
}
// suggested replacement
val iterator =
Iterator.continually(readLine())
.takeWhile(_ != null)
// replace Iterator.continually with Stream.continually if you want something
// that can be iterated over more than once
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.