Bugs: Browse | Submit New | Admin
This wasn't clear from the docs, or the example, but I tried it: $ irb < ivarset.rb >> class Fred >> def initialize(p1, p2) >> @a, @b = p1, p2 >> end >> end => nil >> fred = Fred.new('cat', 99) => #<Fred:0x2fd764 @a="cat", @b=99> >> fred.instance_variable_set(:@a, 'dog') => "dog" >> fred.instance_variable_set(:@c, 'cat') => "cat" >> fred.inspect => "#<Fred:0x2fd764 @a=\"dog\", @b=99, @c=\"cat\">" >>
Add A Comment:
Date: 2007-05-30 04:03 Sender: Ryan Davis no patch