Skip to content

Instantly share code, notes, and snippets.

@dfinninger
Created February 18, 2015 16:22
Show Gist options
  • Save dfinninger/cd69bd4e8ceac6aefb76 to your computer and use it in GitHub Desktop.
Save dfinninger/cd69bd4e8ceac6aefb76 to your computer and use it in GitHub Desktop.
class MyGroup
def initialize
@all = []
end
def add(thing)
@all << thing
end
def each
return to_enum(:each) unless block_given?
yield @all
end
end
asdf = MyGroup.new
asdf.add "hello"
asdf.each { |x| puts x }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment