Created
January 13, 2016 16:53
-
-
Save sashaegorov/45d99a05782018ef0dc4 to your computer and use it in GitHub Desktop.
Revisions
-
sashaegorov created this gist
Jan 13, 2016 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,38 @@ class Parent attr_accessor :a, :b def initialize(a) @a = a end private def set_b @b = 'b' end end class Child < Parent attr_accessor :c def initialize(c) @c = c end def set_c set_b end end c = Child.new('x') # => #<Child:0x007f9989919680 @c="x"> c.a # => nil c.b # => nil c.c # => "x" c.set_c # => "b" c.a # => nil c.b # => "b" c.c # => "x"