15 May 18:25
Contionnal sum
From: Fernando Perez <pedrolito <at> lavache.com>
Subject: Contionnal sum
Newsgroups: gmane.comp.lang.ruby.general
Date: 2008-05-15 16:26:24 GMT
Subject: Contionnal sum
Newsgroups: gmane.comp.lang.ruby.general
Date: 2008-05-15 16:26:24 GMT
Hi,
I am wondering if it is possible to create a conditionnal sum.
For instance I would like to do something like this:
@total_amount = @orders.sum { |order| order.amount if order.paid == true
}
--
--
Posted via http://www.ruby-forum.com/.
RSS Feed