Skip to content

Instantly share code, notes, and snippets.

@dscataglini
Created April 21, 2009 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dscataglini/99137 to your computer and use it in GitHub Desktop.
Save dscataglini/99137 to your computer and use it in GitHub Desktop.
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