Skip to content

Instantly share code, notes, and snippets.

@sandro
Created January 23, 2009 01:10
Show Gist options
  • Save sandro/50824 to your computer and use it in GitHub Desktop.
Save sandro/50824 to your computer and use it in GitHub Desktop.
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