From: Joshua Chia Date: 2007-08-04T02:38:52+09:00 Subject: Running multiple closures per iteration Is there a way to run more than one closure per iteration through a collection? For example, if I want to do the following two things, can I combine them so that I only end up with one pass over the collection, without doing a manual for loop? o = a.select {|x| x >= 0} p = a.inject(0) {|s, x| s += x} Such a combination is useful when iterating through a collection is expensive, e.g. on a large file on a slow disk. -- Posted via http://www.ruby-forum.com/.