Skip to content

Instantly share code, notes, and snippets.

@beakr
Created April 14, 2012 15:14
Show Gist options
  • Save beakr/2385144 to your computer and use it in GitHub Desktop.
Save beakr/2385144 to your computer and use it in GitHub Desktop.
class Drinks < Array
def initialize(&block)
instance_eval &block
end
# Add drink to array
def drink(d)
self << d
end
end
add_drinks = Drinks.new do
drink "water"
drink "soda"
drink "juice"
end
puts add_drinks #=> ["water", "soda", "juice"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment