From: Nikolai Weibull
[mailto:mailing-lists.ruby-talk@rawuncut.elitemail.org]
Sent: Sunday, August 07, 2005 5:43 AM
To: ruby-talk ML
Subject: Adding yet another Array.new formHow about adding a fifth way of constructing new arrays?:
Array.new{|array| block }
Conflicts with the current 4th form, unless you want a "no argument but
block exists" form, e.g. Array.new(x){ .. } would be different from
Array.new{ .. }.
The Array.new source is already a mish-mash of if-else statements.
Adding this would just add another layer of goo to already ugly source
code.
If anything, we should remove the 3rd form altogether, Array.new(ary),
and replace the 4th form with what (I think) has been suggested in later
replies to this thread, i.e. yield self if block_given? for most, if not
all, constructors.
Here, array is the newly created array, and the block will
initialize it as it sees fit, e.g,ary = Array.new{ |ary| 5.times{ |i| ary << i } },
Just to clarify, what should "ary" look like at the end of this example?
Regards,
Dan
···
-----Original Message-----