From: paul Date: 2006-12-03T22:55:08+09:00 Subject: Re: Simple and stuppid bug (can anyone find it?) :) thanks all for the educating responses. Martin, I really liked you suggestion. Let me explain the reason why I did want to chain assignments: I have a class that has a lot of attributes that can be written at creation of an instance. To save my typing the whole lot I made a constructor getting all those attributes. Though, I expect a lot more attributes in the near future. Since the attributes are not mandatory for creating the instance using the constructor-method seemed a little rigid. My second idea was to use attr_writer to set all the properties, but chaining seemed saving me some lines (these assignments aren't that exciting after all). Is there any moral/principal reason to write: A.a = "AA" A.b = "BB" instead of: A.set_b("BB").set_a("AA") ? Cheers, Paul Martin DeMello schreef: > On 12/3/06, paul wrote: > > Hi all, > > I thought it to be good programming style to make attribute assignment > > chainable. When using the attr_writer an assignment returns te value > > assigned which is not what I want, so I tried to do-it-myself. > > If you do want to do this, I'd suggest an attr_setter method, that > generates both foo= and set_foo methods. Then you can chain via > > a.set_a(100).set_b(10) > > which looks much better than the a.a=(100).b=(10) > > martin