On Wed, May 5, 2010 at 11:50 PM, Mike Austin <mike_ekim / yahoo.com> wrote: > > So if a new context is created for every block call in map(), in > theory it should be slower than a for-in loop, correct? ¨Â§ìèáöå ôï > try it when I get home. > > Mike > > No not really (at least for 1.9) http://gist.github.com/391953 here is the output ruby -v loops.rb ruby 1.9.1p378 (2010-01-10 revision 26273) [i686-linux] Rehearsal ---------------------------------------- loop 1.340000 0.000000 1.340000 ( 1.508669) each 1.340000 0.010000 1.350000 ( 1.388928) ------------------------------- total: 2.690000sec user system total real loop 1.380000 0.010000 1.390000 ( 1.419883) each 1.370000 0.000000 1.370000 ( 1.417870) ruby -v loops.rb ruby 1.8.7 (2009-06-12 patchlevel 174) [i486-linux] Rehearsal ---------------------------------------- loop 3.690000 0.650000 4.340000 ( 4.927702) each 4.570000 0.770000 5.340000 ( 5.764859) ------------------------------- total: 9.680000sec user system total real loop 4.000000 0.630000 4.630000 ( 4.739408) each 4.510000 0.680000 5.190000 ( 5.489487) My naý×e interpretation would be that the closure is here anyway only that with for in it contains a ref to i and with each a copy. Memory usage should be up though. Cheers R. -- The best way to predict the future is to invent it. -- Alan Kay