hi!
I have a hash, each value is an array.
I want to build a new array containing the size of each value/array.
Example:
the hash
{"A"=>["1", "2", "3"], "B"=>["b", "toto"]}
the result
[3, 2]
thanks for your help
hi!
I have a hash, each value is an array.
I want to build a new array containing the size of each value/array.
Example:
the hash
{"A"=>["1", "2", "3"], "B"=>["b", "toto"]}
the result
[3, 2]
thanks for your help
some_hash.values.map { |v| v.size }
and in 1.9, I believe you can do:
some_hash.values.map(&:size)