Skip to content

Instantly share code, notes, and snippets.

@hackervera
Created September 22, 2010 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save hackervera/592165 to your computer and use it in GitHub Desktop.
Save hackervera/592165 to your computer and use it in GitHub Desktop.
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