From: Brian Candler Date: 2011-01-27T16:13:31+09:00 Subject: Re: Enumerable.inject_with_index? Colin Bartlett wrote in post #977259: > I'm curious as to when and why people use each_with_index and/or > inject, etc, instead of a somewhat less elegant, and admittedly > possibly less flexible, more direct approach. I think you answered it yourself: people will generally choose the more elegant and/or clearer solution (by their own assessment of 'clearer'). Unless this is the innermost loop of a program which processes a large dataset, and you've used a profiler to prove that this is the hotspot in your particular application, the performance difference doesn't matter a hoot. -- Posted via http://www.ruby-forum.com/.