Skip to content

Instantly share code, notes, and snippets.

@dyoder
Created October 9, 2008 19:37
Show Gist options
  • Save dyoder/15863 to your computer and use it in GitHub Desktop.
Save dyoder/15863 to your computer and use it in GitHub Desktop.
ypcmc02106:pages dyoder$ irb
irb(main):001:0> class A ; attr_accessor :foo ; def initialize; foo = String.new ; end ; end
=> nil
irb(main):002:0> a1 = A.new
=> #<A:0x86970>
irb(main):003:0> a2 = a1.dup
=> #<A:0x82a64>
irb(main):004:0> a1.foo = 'hello'
=> "hello"
irb(main):005:0> a2.foo
=> nil
irb(main):006:0> a2.foo = 'goodbye'
=> "goodbye"
irb(main):007:0> a1.foo
=> "hello"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment