From: dblack@... Date: 2007-08-02T00:10:44+09:00 Subject: Re: change method Array.new? (Was: Unexpected behavior with multidimensional arrays) Hi -- On Wed, 1 Aug 2007, Dan Zwell wrote: > What would you guys think about removing the second parameter from Array.new > ? I suggest this for 2 reasons: > > If the object is a pass-by-copy class such as > Array.new(n, true), or Array.new(n, 23) > then this syntax is exactly the same as > Array.new(n) {true}, or Array.new(n) {23} > > If the object is a pass-by-reference, such as > Array.new(n, Klass.new) > this can be represented by > k=Klass.new > Array(n) {k} > This syntax is less pretty, but does anybody even Array.new this way? It's a > sort of nice piece of syntactic sugar, but I don't see how it's actually > useful. Please correct me if I'm wrong about this. > > If all of the above is true, I would suggest removing the second parameter > from this method, because it confuses plenty of newcomers. I love not confusing newcomers, but at the same time I don't think that something orthogonal and purposeful should be removed from the language just for that reason. In the end, the main target audience for Ruby is non-newcomers. Think of it as a rite of passage :-) Sort of like realizing that: array.each {|a| puts a } can be written as: puts array or that ^ and $ operate per line rather than per string in regular expressions. David -- * Books: RAILS ROUTING (new! http://www.awprofessional.com/title/0321509242) RUBY FOR RAILS (http://www.manning.com/black) * Ruby/Rails training & consulting: Ruby Power and Light, LLC (http://www.rubypal.com)