From: Robert Dober Date: 2010-05-04T20:39:45+09:00 Subject: Re: Calculation in a block On Tue, May 4, 2010 at 12:59 PM, Chandramouli Parasuraman wrote: I would be more rubymatic here ;) 1000.times.inject{ | sum_so_far, next_number | if (next_number % 3).zero? || (next_number % 5).zero? sum_so_far + next_number else sum_so_far end } It might be exaggerated to use the implicit form of inject just because the first value is zero (it will be passed to sum_so_far in the first iteration) inject(0){ | sum_so_far, next_number | } might have been more readable HTH R. -- The best way to predict the future is to invent it. -- Alan Kay