Skip to content

Instantly share code, notes, and snippets.

@shrkw
Last active November 11, 2015 10:06
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/36dbdf9d62383ca4bacc to your computer and use it in GitHub Desktop.
Save shrkw/36dbdf9d62383ca4bacc 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.to_proc.curry(1).call(self) }
l.call &:bark
l.call &:mew
l.call &: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