Skip to content

Instantly share code, notes, and snippets.

@chrisseaton
Created July 30, 2018 16:36
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 chrisseaton/157b9d83bfe3f65e3682088ff3c6b5c4 to your computer and use it in GitHub Desktop.
Save chrisseaton/157b9d83bfe3f65e3682088ff3c6b5c4 to your computer and use it in GitHub Desktop.
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