Ruby reduzieren Hash
hash = { foo: 1, bar: 2 }
# sum up all values of the hash
# start with 0
# \/
result = hash.inject(0) { |sum, key_value| sum + key_value.last }
#=> 3
Mateusz Drewniak