From: Daniel Berger Date: 2007-01-19T06:35:09+09:00 Subject: Re: auto assign arguments? David Chelimsky wrote: > I see where to put bugs and patches, but this is a feature request. Is > this the right place to submit these? > > In any case, here's a feature request: > > I find that I do a lot of this: > > def initialize(thing, other) > @thing = thing > @other = other > end > > One thing I'd love to see in a future version of ruby is this; > > def initialize(@thing, @other) > end > > .. and have that automagically initialize @thing and @other with the > submitted values. I could have sworn Paul Brannan did this as part of RubyTreasures, but I don't see any such thing mentioned in the docs. I know it's been done somewhere as a language hack. Personally, I think it ought to be the default behavior, since it's what you want about 80% of the time in practice I think. At worst, you've got a couple of useless instance variables that people would have to go to pains to get at via instance_variable_get. Heck, why not take this a step further and create automatic getters and setters? You can always undef or redefine them. Regards, Dan