From: Igor Pirnovar Date: 2012-10-26T01:25:46+09:00 Subject: Re: Name/symbol/object type clash? What is happening here? Robert Klemme wrote in post #1081146: > I strongly object. Struct is a very useful tool I use all the time to > define data containers quickly. >> The above problem can be solved if you use accessor methods in place of >> '@' variable: > > Exactly. I have no objection if anybody wishes to use the broken Struct as it is in his/her own short-cuts and sketches. However, if allowed there, who is going to prevent its use in main-stream programming? The trouble is, this stuff is so broken in situations becomes totally useless. Its inconsistencies with regular ruby classes make things unacceptable on the first place, and I can not believe anyone would defend its continuous usage in this broken fashion! If it is so bloody useful, fix the darn thing so it doesn't introduce unnecessary exceptions to the impeccable consistent and beautiful Ruby oo language! Try to fix the following without redefining the redefining accessor for 'num' instance variable within the class definition hence invalidating the use of Struct: S = Struct.new(:num) class S attr_accessor :num def initialize(n); @num=n+5; end def num=(n); @num = n+5; end end s = S.new(3) puts s.num #=> 8 s.num = 4 puts s.num #=> 9 Regards, Igor -- Posted via http://www.ruby-forum.com/.