Created
February 19, 2014 19:10
-
-
Save SethTisue/9099321 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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