Created
June 2, 2015 12:46
-
-
Save frhack/7819a6a4fad065851d0c to your computer and use it in GitHub Desktop.
Groovy break and continue in closures
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
/* | |
With rx-java you can transform an iterable in to an observable. | |
Then you can replace continue with a filter and break with takeWhile | |
Here is an example: | |
*/ | |
import rx.Observable | |
Observable.from(1..100000000000000000) | |
.filter { it % 2 != 1} | |
.takeWhile { it<10 } | |
.forEach {println it} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment