Skip to content

Instantly share code, notes, and snippets.

@xenda
Created December 5, 2011 01:17
Show Gist options
  • Save xenda/1431898 to your computer and use it in GitHub Desktop.
Save xenda/1431898 to your computer and use it in GitHub Desktop.
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