Guest User

Untitled

a guest
Mar 14th, 2018
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.23 KB | None | 0 0
  1. totalcost = items.inject(0) {|sum, hash| sum + hash[:cost]}
  2.  
  3. puts totalcost
  4.  
  5. totalcost = items.map { |x| x[:cost].to_f }.sum
  6.  
  7. sprintf("%.2f", totalcost)
  8.  
  9. totalcost = items.inject(0) {|sum, hash| sum + hash[:cost].to_f}
Add Comment
Please, Sign In to add comment