Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- totalcost = items.inject(0) {|sum, hash| sum + hash[:cost]}
- puts totalcost
- totalcost = items.map { |x| x[:cost].to_f }.sum
- sprintf("%.2f", totalcost)
- totalcost = items.inject(0) {|sum, hash| sum + hash[:cost].to_f}
Add Comment
Please, Sign In to add comment