Skip to content

Instantly share code, notes, and snippets.

@ngw
Created March 23, 2011 09:58
Show Gist options
  • Save ngw/882879 to your computer and use it in GitHub Desktop.
Save ngw/882879 to your computer and use it in GitHub Desktop.
>> class Foo
>> def initialize arg
>> @attr = arg
>> end
>> attr_accessor :attr
>> def attr=( arg )
>> puts 'HA!'
>> end
>> end
>> Foo.new 'test'
=> #<Foo:0x1012f55d8 @attr="test">
>> class Foo
>> def initialize arg
>> self.attr = arg
>> end
>> end
=> nil
>> Foo.new 'test'
HA!
=> #<Foo:0x1012d9270>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment