I like it!

-----Original Message-----
From:	Dave Thomas [SMTP:Dave / PragmaticProgrammer.com]
Sent:	Monday, February 26, 2001 4:21 PM
To:	ruby-talk ML; ruby-talk / netlab.co.jp
Subject:	[ruby-talk:11633] RCR: shortcut for instance variable initialization


I'm sure this will break all sorts of stuff, but just in case it
doesn't:


I'm constantly creating small classes, and many of them start
something like:

  class Msg
    def initialize(name, type, txt)
      @name, @type, @txt = name, type, txt
    end
    # ...
  end

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

This would also bring methods one step closer to blocks :)


I want to thank the committee for this opportunity of presenting a
request, and wish them all good health and fortune.

Dave