James Gray wrote:
> On May 31, 2006, at 2:44 PM, transfire / gmail.com wrote:
> 
>> They are the same. A for-loop is "translated" into an each-loop.
> 
> Well, almost:
> 
>  >> things = [1, 2, 3]
> => [1, 2, 3]
>  >> things.each { |thing| }
> => [1, 2, 3]
>  >> thing
> NameError: undefined local variable or method `thing' for main:Object
>          from (irb):3
>          from :0
>  >> for thing in things
>  >>   # ...
> ?> end
> => [1, 2, 3]
>  >> thing
> => 3
> 
> James Edward Gray II

Valid.  But as long as you're not interested in manipulating that last 
element outside of the loop, they're functionally equivalent.

Thanks for everyone for the good info.

Wes


-- 
Posted via http://www.ruby-forum.com/.