# noinspection RubyStringKeysInHashInspection,RubyStringKeysInHashInspection,RubyStringKeysInHashInspection,RubyStringKeysInHashInspection,RubyStringKeysInHashInspection,RubyStringKeysInHashInspection
ages = { 'Herman' => 32, 'Lily' => 30, 'Grandpa' => 5843, 'Eddie' => 10, 'Marilyn' => 22, 'Spot' => 237 }

# My method
ages_array = Array.new

ages.each do |key, value|
  ages_array << value
end

p ages_array.sum

# Recommended method
total_ages = 0
ages.each { |_, age| total_ages += age }
p total_ages

# Alternative method
p ages.values.inject(:+)
