From: Phrogz Date: 2006-11-29T00:10:10+09:00 Subject: Re: find index of first non zeo value in array Devin Mullins wrote: > Phrogz wrote: > > Hrm, I assumed that using #each_with_index would be speedier, since > > there would be no Ruby call to the #[] method of the array for each > > iteration. Instead, it's much slower: > Hrm, that is odd. I assure you it was purely by accident that I picked > the faster implementation. Maybe it has something to do with > each_with_index being implemented by Enumerable, vice Array? I dunno > why.... should just delegate to each, and keep a counter around. My totally uninformed guess is that it has something to do with more than one parameter to the block, possibly creating a temporary array for the value/index pair and then splatting them on each call.