Skip to content

Instantly share code, notes, and snippets.

@jasonroelofs
Forked from hackervera/animal.rb
Created September 22, 2010 18:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonroelofs/592175 to your computer and use it in GitHub Desktop.
Save jasonroelofs/592175 to your computer and use it in GitHub Desktop.
class Animal
def noise(sound, &block)
block.call(sound)
end
end
class Cow < Animal
def moo(&block)
noise("moo", &block)
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