From: Karthik Nar Date: 2007-01-15T18:37:33+09:00 Subject: Re: How does Array.map work for 2D arrays? yes makes sense!! here's some experiments i did, and it's more of a ruby thing than a map thing! irb(main):001:0> a = 1, 2 => [1, 2] irb(main):002:0> def map(a) yield a end => nil irb(main):003:0> map(a) { | x, y | p y } 2 => nil irb(main):004:0> map(a) {| x | p x } [1, 2] => nil > Two points. First, I don't know how it figures it out. Second, your > question can be "answered" by looking at another example... > > a = [ [ 'billy', 'goat', 'cheese' ], [ 'silly', 'hats' ] ] > > a.map { |x, y, z| z } # => ["cheese", nil] > > Observation tells us that map isn't really figuring out that you have a > 2D array, it's simply assuming that if you're asking for two arguments > (or three or one-hundred), that your array has them. > > Make sense? -- Posted via http://www.ruby-forum.com/.