> No. Consider: you have something (in working code) that accepts > two parameters, and every time it is called, it receives two > parameters. The code, as written, has been well tested and is known to > work. > If you add a default value to the second parameter, for use by > newly written code, you would expect the old code (which always provides > two values) to continue to function correctly. It would, under 1.8.0, > and any other language I can think of that allows for default > parameters. > > But if some users were depending on auto-array-explosion under the > semantics proposed above, the old code would silently break; the array > that had auto-expanded when there were two REQUIRED parameters would > quietly stop exploding. OK, point taken; a quick check confirms you can make optional parameters in blocks, i.e. foo { |a,*b| p a,b } [although not |a,b=nil| like you can have in method definitions] > 1. As people have previously pointed out, there is no actual > kv_array; it should, if anything, be a new class (an > Association) > 2. Since the array supposedly being exploded is inside the > definition of Hash#each, it would only have to be changed in > this one place (by adding an "*") to make it explicit in any > case. It's a bit of a pain to fiddle with the internal working of existing iterators though; you'd have to wrap them something like class Foo def exploded_each(*args) each(*args) { |a| yield *a } end end > 3. What's really going on is auto IMPLOSION, analogous to: > > yield(k0,v0) > > ... { |kv| ... > ... { |k,v| ... Ah, right. I was assuming Hash#each doing "yield [k,v]", when it seems it actually does "yield k,v" (yep, looking at each_pair_i in hash.c) In that case, if it can be imploded into a pair [k,v] automatically for the purposes of Enumerable, then perhaps you're right, the problem goes away. In which case, why does auto-explosion happen at all? Can someone provide some compelling examples where it is needed? Regarding Associations though: if Hash#each did start returning these, you would clearly not be able to do myhash.each { |k,v| ... } any more. So you'd probably want a new interator for that case: myhash.each_pair { |k,v| ... } # already exists or myhash.each_with_index { |v,k| ... } # like an array Regards, Brian.