Skip to content

Instantly share code, notes, and snippets.

@shrkw
Created November 18, 2015 16:56
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 shrkw/9066f4b81fda8f4983e7 to your computer and use it in GitHub Desktop.
Save shrkw/9066f4b81fda8f4983e7 to your computer and use it in GitHub Desktop.
class Animal
def initialize(species)
@species = species
end
def bark()
"bowbow"
end
def mew()
"mewwww"
end
def tweet()
"piyopiyo"
end
def makeASound
l = -> &sound { p @species + " makes a sound"; p sound.call }
l.call &method(:bark)
l.call &method(:mew)
l.call &method(:tweet)
end
end
Animal.new("Dog").makeASound
# "Dog makes a sound"
# "bowbow"
# "Dog makes a sound"
# "mewwww"
# "Dog makes a sound"
# "piyopiyo"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment