From: Mayuresh Kathe Date: 2008-09-01T21:00:38+09:00 Subject: accessing instance variable Hello, I did the following; class O @b = 0 def x=(a) @b = a end end o = O.new o.x = 1 I then tried to access b by doing; c = o.b but irb gave me the following error; NoMethodError: undefined method `b' for # from (irb):10 from /usr/lib/ruby/1.9.0/irb.rb:150:in `block (2 levels) in eval_input' from /usr/lib/ruby/1.9.0/irb.rb:259:in `signal_status' from /usr/lib/ruby/1.9.0/irb.rb:147:in `block in eval_input' from /usr/lib/ruby/1.9.0/irb.rb:146:in `eval_input' from /usr/lib/ruby/1.9.0/irb.rb:70:in `block in start' from /usr/lib/ruby/1.9.0/irb.rb:69:in `catch' from /usr/lib/ruby/1.9.0/irb.rb:69:in `start' from /usr/bin/irb1.9:13:in `
' how do I access an instance variable if not via object.instance_variable? Best, --