Skip to content

Instantly share code, notes, and snippets.

@kirs
Created June 20, 2018 12:48
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 kirs/b2cc6aa66874d68e4137470c98e12537 to your computer and use it in GitHub Desktop.
Save kirs/b2cc6aa66874d68e4137470c98e12537 to your computer and use it in GitHub Desktop.
iter = Enumerator.new do |yielder|
yielder.yield "start"
3.times { |n| yielder.yield(n) }
yielder.yield "end"
end
# iter.each do |n|
# puts n
# end
class Example
include Enumerable
def initialize
@omg = [1, 2, 3]
end
def each
@omg.each do |el|
yield el
end
end
end
Example.new.each do |n|
puts n
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment