Hi --

On Thu, 2 Mar 2006, Yukihiro Matsumoto wrote:

> Hi,
>
> In message "Re: Hash.from_zipped_array"
>    on Thu, 2 Mar 2006 06:12:08 +0900, dblack / wobblini.net writes:
>
> |I may be in the minority, but I prefer:
> |
> |   Hash[*arr.flatten_once]
> |
> |:-)
>
> I'm not sure above is the best solution, but anyway giving #flatten a
> level argument could be useful, so that you can do:
>
>   Hash[*arr.flatten(1)]
>
> It's more general, and even shorter.

Actually the flattenx extension has both: flatten_once and flatten(n)
for any n.  I can't remember why I included flatten_once -- I guess
because it seemed to be the most common case and I liked giving it its
own name.


David

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

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