Totalling All of a Variable

/ Published in: Ruby
Save to your folder(s)

This will add up all the prices and return it?
What does |item| mean exactly?

Copy this code and paste it in your HTML
  1. @items.sum { |item| item.price }

Report this snippet


RSS Icon Subscribe to comments

You need to login to post a comment.