Skip to content

Instantly share code, notes, and snippets.

@SethTisue
Created February 19, 2014 19:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SethTisue/9099321 to your computer and use it in GitHub Desktop.
Save SethTisue/9099321 to your computer and use it in GitHub Desktop.
// 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