Last active
December 27, 2015 10:09
-
-
Save mohayonao/7309372 to your computer and use it in GitHub Desktop.
iterator
This file contains hidden or 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
i = Iterator -> | |
x = 0 | |
@yield x # 0 | |
x += 10 | |
@yield x # 10 | |
x += 10 | |
if no | |
@yield "skipped" | |
else if yes | |
@yield x | |
x += 10 | |
@yield x # 30 | |
i.next() #=> 0 | |
i.next() #=> 10 | |
i.next() #=> 20 | |
i.next() #=> 30 | |
i.next() #=> null |
This file contains hidden or 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
i = Iterator -> | |
[x] = [] | |
[ | |
=> | |
x = 0 | |
@yield x | |
=> | |
x += 10 | |
@yield x | |
=> | |
x += 10 | |
if no | |
@yield "skipped" | |
else if yes | |
@yield x | |
=> | |
x += 10 | |
@yield x | |
] | |
i.next() #=> 0 | |
i.next() #=> 10 | |
i.next() #=> 20 | |
i.next() #=> 30 | |
i.next() #=> null |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment