#### Topic: Array Calculation Question

I have two arrays that each contain values from a find_by_sql.

@totals is the amount due, which has one value in it.

@payments is an array with 0 or more values.

What I am trying to do is display the total remaining. That is to say the value in @totals minus the sum of the values in @payments.

I can get them to display separately using something like:

`<% @payments.each do |payment| %> <%= payment["amount"] %> <% end %>`

How can I subtract the sum of all values in @payments from the one value in @totals?

The best I've been able to produce is a memory location...

*Last edited by Fienix (2011-09-17 21:01:32)*