Created
July 30, 2018 16:36
-
-
Save chrisseaton/157b9d83bfe3f65e3682088ff3c6b5c4 to your computer and use it in GitHub Desktop.
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
string = 'hello' | |
enumerators = [] | |
loop do | |
1000.times do | |
e = string.each_byte | |
e.next # Has to create a fiber to run `each_byte` in | |
# so it can pause in the method waiting for | |
# you to call #next again. | |
enumerators << e | |
p enumerators.size | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment