hash.flatten â an_array
hash.flatten(level) â an_array
hash.flatten(level) â an_array
Instance Public methods
Returns a new array that is a one-dimensional flattening of this hash. That is, for every key or value that is an array, extract its elements into the new array. Unlike Array#flatten, this method does not flatten recursively by default. The optional level argument determines the level of recursion to flatten.
1 2 3 | a = { 1 => "one" , 2 => [ 2 , "two" ], 3 => "three" } a.flatten # => [1, "one", 2, [2, "two"], 3, "three"] a.flatten( 2 ) # => [1, "one", 2, 2, "two", 3, "three"] |
Please login to continue.