Mathieu Bouchard wrote: >On Tue, 27 Feb 2001, Dave Thomas wrote: >> So, could we change parameter passing slightly so that if an instance >> method has a formal parameter starting with an '@' sign, the incoming >> value is assigned directly to the corresponding instance variable? >> Using this scheme I could write the above as: >> class Msg >> def initialize(@name, @type, @txt) >> end >> end > >I agree with that change. > >This also makes an attribute writer something like: > >def some_attr=(@some_attr); end Hmmmmmm. I can see the value for the initialize method. But we alerady have an attribute writer shortcut, so the latter doesn't help me. I'm concerned that ANY method can smack your member variables when you might have just accidentally put the @ in out of habit from writing it so many times elsewhere. It just makes me a little nervous. Could we say that initialize is the only method to get this special treatment? Or is there some way to have one line of code that means "copy each of the passed parameters into member variables with corresponding names"? This would allow something like this: def initialize(name, type, txt) set_locals_to_params ... more code here... end Kevin