Created
April 14, 2012 15:14
-
-
Save beakr/2385144 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
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