From: Robert Dober Date: 2007-01-19T22:15:33+09:00 Subject: Re: auto assign arguments? ------=_Part_157796_21873590.1169212512966 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 1/19/07, dblack@wobblini.net wrote: > > Hi -- > > On Fri, 19 Jan 2007, David Chelimsky wrote: > > > Wow. You guys are all coming up w/ great alternatives, but would > > somebody please just answer my question? I am not asking for ways to > > do what I want. I'm asking if you think the following proposed syntax > > addition would be useful: > > > > Any parameter preceded by a @ results in an instance variable being > > created and initialized with the submitted value. So: > > > > class MyClass > > def initialize(@a) > > end > > end > > > > instance = MyClass.new(5) > > #results in an instance variable @a with a value of 5 > > That was proposed as an RCR and rejected; see > http://oldrcrs.rubypal.com/rejected.html#rcr3 > > > David > > -- > Q. What is THE Ruby book for Rails developers? > A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) > (See what readers are saying! http://www.rubypal.com/r4rrevs.pdf) > Q. Where can I get Ruby/Rails on-site training, consulting, coaching? > A. Ruby Power and Light, LLC (http://www.rubypal.com) > > It was rejected more than 5 years ago and without any reason. The RCR was very short. I feel that this could be presented again, be motivated much better (e.g. indicating that instance variables can be block parameters) etc.etc. Right now you can *already* write code like this class B attr_reader :a define_method :initialize do |@a| ; end end b=B.new 42 b.a => 42 I feel that this is worth another shot, maybe Matz could tell us to stop working on this if he really does not like it. It seems reasonable to assume that the reasons he had to reject the RCR do not exist anymore or that he has changed his mind, no? Cheers Robert -- "The best way to predict the future is to invent it." - Alan Kay ------=_Part_157796_21873590.1169212512966--