I have a hash that maps integers to arrays. For example
{1 => [\"abc\"], 2 => [\"ccc\", \"ffffd\"]}
How do I get all the keys from my hash
Anything like this?
hash.each_key.select { |key| hash[key].count >= 2 }
One more possible solution :)
{1 => ["abc"], 2 => ["ccc", "ffffd"]}.map { |k, v| k if v.size > 1 }.compact # => [2]
{1 => ["abc"], 2 => ["ccc", "ffffd"]}.select{|_, a| a.length > 1}.keys # => [2]