Rewind it before using each.
in reply to Re: Ouch! Each! Reentrant it is not
in thread Ouch! Each! Reentrant it is not
I did that at first, but then I changed it to rewind after use.
Because if you rewind it only before, and then leave the iterator "open", your own piece of code is fine, but it will greatly confuse the next person who happens to call keys, values or each. So I decided that cleaning up after myself is the better way here.
Update As pointed out by ysth, it would only greatly confuse any other users of each, and not affect keys or values.