Created
April 20, 2010 19:06
-
-
Save napcs/372906 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 Person | |
def say_hello | |
"Hello" | |
end | |
end | |
class Person | |
def say_goodbye | |
"goodbye" | |
end | |
end | |
p = Person.new | |
puts p.say_hello | |
puts p.say_goodbye | |
class Person | |
def say_goodnight | |
"goodnight" | |
end | |
end | |
puts p.say_goodnight | |
p2 = Person.new | |
class << p2 | |
def say_hello | |
"Hi there!" | |
end | |
end | |
puts p2.say_hello | |
puts p.say_hello | |
p3 = Person.new | |
def p3.say_hello | |
"Hola!" | |
end | |
puts p3.say_hello | |
puts p2.say_hello | |
puts p.say_hello |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment