Created
April 21, 2009 13:27
-
-
Save dscataglini/99137 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 | |
attr_accessor :b | |
end | |
class B | |
end | |
def change_A x | |
x.b = 1 | |
end | |
def change_locally x # => locally named variable now pointing to passed reference | |
x = B.new # => local variable now pointing to something new | |
end | |
a = A.new # => assign instance of object A to a | |
puts change_A(a) | |
puts a.b | |
puts change_locally(a) | |
puts a.b |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment