Created
December 5, 2011 01:17
-
-
Save xenda/1431898 to your computer and use it in GitHub Desktop.
This file contains 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 Duck | |
def talk | |
puts "quack!" | |
end | |
end | |
class Cow | |
def talk | |
puts "mooo!" | |
end | |
def get_milk | |
puts "Mooo! You've got now milk for TheFricky!" | |
end | |
end | |
class Mouse | |
def talk | |
puts "squeak!" | |
end | |
end | |
def give_me_something | |
animals = [Duck, Mouse, Cow] | |
animals[rand(2).new] | |
end | |
some_variable = give_me_something | |
some_variable.talk | |
some_variable.get_milk if some_variable.respond_to? :get_milk | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment