From: Charles Oliver Nutter Date: 2008-09-22T00:44:23+09:00 Subject: Re: for or each? Joe Wölfel wrote: > You can try my test if you like. I haven't checked it carefully. But > it does seem like 'each' is much faster under both ruby 1.86 and ruby > 1.9. The code is below. Odd, now that I try it, each *is* faster than for. I'm going to have to investigate. JRuby: user system total real for loop 0.334000 0.000000 0.334000 ( 0.334033) each 0.236000 0.000000 0.236000 ( 0.235695) Ruby 1.8.6: user system total real for loop 1.050000 0.010000 1.060000 ( 1.079704) each 0.950000 0.010000 0.960000 ( 0.982576) Ruby 1.9: user system total real for loop 0.910000 0.010000 0.920000 ( 0.933510) each 0.420000 0.000000 0.420000 ( 0.431548) - Charlie