On 07.06.2007 07:42, jbc wrote:
> (I posted this before on the google-group rather than the usenet
> group, but it seems not to have shown up. I don't know why. If this is
> a duplicate for anyone, my apologies)
> 
> def initialize(foo,bar,bat)
>   @foo,@bar,@bat = foo,bar,bat
> end
> 
> Seems clumsy and not at all DRY.
> 
> What would seem the obvious approach to me would be this:
> 
> def initialize(@foo,@bar,@bat)
> end
> 
> Is there a reason it's not done that way?

See the other replies for explanations.  I want to show an alternative:

Foo = Struct.new :foo, :bar, :bat

f=Foo.new 1,2,3

You'll also get comparison logic and hashing for free.  And you can even 
define methods on the class directly like this:

Foo = Struct.new :foo, :bar, :bat do
   def size
      foo + bar + bat
   end
end

I use that pretty often because it saves even more typing than just the 
initialize code. :-)

Kind regards

	robert