Skip to content

Instantly share code, notes, and snippets.

@universal
Created October 10, 2012 12:57
Show Gist options
  • Save universal/3865473 to your computer and use it in GitHub Desktop.
Save universal/3865473 to your computer and use it in GitHub Desktop.
parent / child super calls
class Parent
attr_accessor :something
def print
puts self.something
end
end
class Child < Parent
def print
self.something = "hello"
super
end
end
parent = Parent.new
parent.something = " world!"
child = Child.new
child.print
parent.print
#####
ruby test.rb
hello
world!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment