From: Robert Klemme Date: 2009-11-26T02:45:05+09:00 Subject: Re: Ruby internals & other questions On 25.11.2009 17:29, Aldric Giacomoni wrote: > Ralph Shnelvar wrote: >> y=0 >> 1_000_000.times {|x| y+=x} > > y = (1..1_000_000).inject { |a, b| a + b } There is an issue with this approach. The proper implementation for the general case of summing any number of values would look like this: y = (1..1_000_000).inject(0) { |a, b| a + b } Kind regards robert PS: Yes, I deliberately left out the explanation what the issue is. :-) -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/