foo = [2, 3] bar = [4, 5] sum = Hash.new { |hash, key| hash[key] = key.first + key.last } p sum[foo] p sum[bar] p sum