Closed michaelachrisco closed 9 years ago
The issue, I believe, is that each with index vs while
are fundamentally different. The while loop is adding the ARRAY[index] + index
and then returns nil whereas ARRAY.each_with_index
adds the newly created index
and the number
then returns the initial array. If this test is to be identical, the return value needs to be the initial ARRAY
.
I know this is a small nitpick but l will add in the PR anyway.
:+1:
From: https://github.com/JuanitoFatas/fast-ruby/blob/master/code/enumerable/each_with_index-vs-while-loop.rb In the example code, the return types are returning different objects and may be effecting the overall Benchmarking time. I came across this in another gem. I'll be adding code to see if this is true or not.