I have a hash like this.
products = {199 =>['Shoes', 59.99], 211 =>['Shirts', 19.99], 245 =>['Hats', 25.99], 689 => ['Coats', 99.99], 712 => ['Beanies', 6.99]}
It has an item number => [product, price]
.
I would like to sum up all the prices without using the inject method.
Can anyone help me please?
products.values.map(&:last).reduce(:+) #=> 212.95
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With