On 10/29/2010 4:28 PM, Ted Flethuseo wrote:
> I was wondering if a loop of this sort would be
> effective in ruby for a large number of elements
> 
>     for i in 1..layers[0].count-1
>       puts i
>     end
> 
> Is it equivalent in efficiency to this?
> 
> int i = 1
> while i < layers[0].count-1
>    puts i
> i+=1
> end

I'm not sure about comparative effectiveness, but this is probably more
idiomatic:

(layers[0].count - 1).times do |i|
  puts i+1
end


It's probably also more efficient if only a bit since it does not
require the creation and evaluation of a Range object.

-Jeremy