Ruby hash of arrays – show the key of hash + array size

I need the method which will return hash with keys of old hash and values – size of arrays for keys. I.E.

{ 1 => [1,1,1], 2 => [3,4,5], 7 => [9,12] }
# return
{ 1 => 3, 2 => 3, 7 => 2 }

Is there any way to implement this?


Source: ruby

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.