wow, robert, that makes a lot of sense Thanks ! now my next question: how would a newbie (like me) know by looking at the ruby doc that Array.map could actually support 2D arrays in this fashion? (or is it that it just becomes "obvious" as one uses Ruby more and more?!) Robert Klemme wrote: > > It doesn't really have to do anything at all: > > irb(main):001:0> def foo() yield 1,2 end > => nil > irb(main):002:0> foo {|a| p a} > (irb):2: warning: multiple values for a block parameter (2 for 1) > from (irb):1 > [1, 2] > => nil > irb(main):003:0> foo {|*a| p a} > [1, 2] > => nil > irb(main):004:0> foo {|a,b| p a} > 1 > => nil > irb(main):005:0> def foo() yield [1,2] end > => nil > irb(main):006:0> foo {|a| p a} > [1, 2] > => nil > irb(main):007:0> foo {|*a| p a} > [[1, 2]] > => nil > irb(main):008:0> foo {|a,b| p a} > 1 > => nil > > You see in line 6 and 8 how it works. > > However, map could also evaluate the block's arity: > > irb(main):009:0> def foo(&b) p b.arity; b[1,2] end > => nil > irb(main):010:0> foo {|a| p a} > 1 > (irb):10: warning: multiple values for a block parameter (2 for 1) > from (irb):9 > [1, 2] > => nil > irb(main):011:0> foo {|a,b| p a} > 2 > 1 > => nil > irb(main):012:0> foo {|*a| p a} > -1 > [1, 2] > => nil > irb(main):013:0> def foo(&b) p b.arity; b[[1,2]] end > => nil > irb(main):014:0> foo {|a| p a} > 1 > [1, 2] > => nil > irb(main):015:0> foo {|a,b| p a} > 2 > 1 > => nil > irb(main):016:0> foo {|*a| p a} > -1 > [[1, 2]] > => nil > > HTH > > robert