Created
January 23, 2009 01:10
-
-
Save sandro/50824 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 A | |
def self.say(msg) | |
puts "Hello from A #{msg}" | |
end | |
end | |
class B < A | |
def self.say(msg) | |
if msg.empty? | |
super | |
else | |
puts msg | |
end | |
end | |
end | |
# B.say 'hi' >> 'hi' | |
# B.say '' >> 'Hello from A ' | |
# You don't have to call super with the required argument(s), it gets those passed along, | |
# but if you want to...you can explicitly pass args using super(args) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment