From: Todd Benson Date: 2012-10-24T00:42:50+09:00 Subject: Name/symbol/object type clash? What is happening here? It's nonsense code, but I'm curious as to what is going on behind the scenes... irb(main):001:0> S = Struct.new(:num) => S irb(main):002:0> class S; def change_to n; @num = n; end; end => nil irb(main):003:0> s = S.new(3) # irb(main):004:0> s.num = 4 => 4 irb(main):005:0> s.num => 4 irb(main):006:0> s.change_to(5) => 5 irb(main):007:0> s.num => 4 irb(main):008:0> s.instance_variables => [:@num] irb(main):009:0> s.instance_variable_set(:@num, 5) => 5 irb(main):010:0> s.num => 4 Same thing happens if I don't define class S, but just define a method on the instance... def s.change_to n; @num = n; end