Karthik Nar wrote:
> ... a two-parameter block suppled to map like below:
> 
>>> pt.map  {|disp, value| value} 
> => ["check", "cc", "po"]
> 
> is able to give me the second element of the 2D array.
>
> while, i love this functionality, my question is -
> 
> How does this 2 parameter variant really work?
> 
> How does the array.map "figure out" and pass disp to param1 and value to
> param2?

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/.