Created
November 18, 2015 16:56
-
-
Save shrkw/9066f4b81fda8f4983e7 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 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