I think I've found a gotcha. Really, it should be expected behavior, but 
it wasn't immediately obvious to me, so I thought it's at least worth 
mentioning.

Let's say you want to iterate through an array and delete any items in 
that array that match a certain criteria. I thought it'd make sense to 
do this:

items.each do |x|
	if x == ""
		items.delete(x)
	end
end


If items.each referred to items[] by reference, this would make sense. 
But since it references by value, you're literally changing the array 
live, as you're iterating through it. This means that, if you delete an 
item in mid-iteration, you change the index of items[]. Since you 
deleted something, you skip the next item.

1) Do I have this right?

2) Am I right in assuming that it's possible to create an infinite loop 
this way by continually push()ing things on to items[]?

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