From: Gregory Brown Date: 2007-07-26T04:55:26+09:00 Subject: Re: opposite of [thing].flatten Not an answer to your question: On 7/25/07, Phlip wrote: > Ruby-ists: > > We all know this clever idiom to turn a variable that might be an Array into > one known to be an Array: > > thing = [thing].flatten I think thing = Array(thing) is more idiomatic. >> Array(nil) => [] >> Array("foo") => ["foo"] >> Array(["foo"]) => ["foo"] >> Array([["foo"]]) => [["foo"]] It does not accidentally flatten nested arrays, and does not throw a warning like Object#to_a does