Hi --

On Wed, 8 Mar 2006, Brian Buckley wrote:

> require 'facet/symbol/to_proc'
>
> [[1,2], [], [1,2,3]].map(&:length)  #line 1 Blows up re undefined method
> length for Fixnum?
>
> ["ab", "", "abc"].map(&:length)  #line 2 => [2, 0, 3]  but this works fine
>
> Why does the first line fail by trying to call method length on Fixnum?
> Shouldn't it be calling length on Array (which is defined) and thus return
> [2,0,3] ?  Note the next line behaves as I'd expect, but for Strings.
>
> What's happening?

I'm only guessing but could it be flattening the outer array?


David

-- 
David A. Black (dblack / wobblini.net)
Ruby Power and Light, LLC (http://www.rubypowerandlight.com)

"Ruby for Rails" chapters now available
from Manning Early Access Program! http://www.manning.com/books/black