Quick Ruby Array question

In code like:

for line_item in @cart.line_items
#Do Stuff
end

Am I guaranteed to traverse the array from the first element
successively
through each index number from first to last? If not, what’s the proper
ruby way to do that?

Thanks!

–
Terry (TAD) Donaghe
http://tadspot.tumblr.com

Yes, although #each is more rubyish:

@cart.line_items.each do |line_item|

do stuff

end

Thanks eden!

On 5/6/07, eden li [email protected] wrote:

–
Terry (TAD) Donaghehttp://tadspot.tumblr.com

–
Terry (TAD) Donaghe
http://tadspot.tumblr.com

And if you need the indexes:

@card.line_items.each_with_index do | line_item, index |

Michael