Created
September 22, 2010 18:00
-
-
Save hackervera/592165 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 Animal | |
def noise(sound) | |
yield(sound) | |
end | |
end | |
class Cow < Animal | |
def moo | |
noise("moo") | |
end | |
end | |
animal_noise = lambda {|noise| "This animal goes #{noise}"} | |
harry = Cow.new | |
puts harry.moo(&animal_noise) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment