On 7/25/07, Phlip <phlip2005 / gmail.com> wrote:
> Gregory Brown wrote:
>
> >>> Array([["foo"]])
> > => [["foo"]]
> >
> > It does not accidentally flatten nested arrays, and does not throw a
> > warning like Object#to_a does
>
> Ruby is a strongly-typed language that permits you to write interfaces that
> are as feebly- or strongly-typed (or statically-typed) as you like.
>
> If your interface permits one item or a series of similar items, then those
> nested arrays are not "accidentally" flattened, they are deliberately
> pushed into your interface's contract.
>
> If flattening that deep array and traversing its elements surprises the
> user, then maybe they shouldn't pass arrays in that they convoluted for
> some other reason!

You're right, but what you said is:

"We all know this clever idiom to turn a variable that might be an Array into
one known to be an Array:"

That's not what your 'idiom' does.  It flattens an array that you
create from a single object.  Careful wording is important.