Created
June 20, 2018 12:48
-
-
Save kirs/b2cc6aa66874d68e4137470c98e12537 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
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