my_hash = {
:key_one =>["one", "two", "three", "four", "five"],
:key_two =>["one", "two", "three", "four", "five"]
}
Hash[ my_hash.map { |k,v| [ k, v.first(2) ] } ]
# => {:key_one=>["one", "two"], :key_two=>["one", "two"]}
References:
- Hash[] constructor
- Hash is an Enumerable, so has access to Enumerable#map, and iterates through [key,value] pairs.