daily pastebin goal
46%
SHARE
TWEET

Untitled

a guest Mar 14th, 2018 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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}
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top