Surprising behavior of for...in loop