|
It seems that assigning nil to a non-existant entry 'can' cause an
error. Try the following code: list = { a = 1, b = 2, c = 3, d = 4, e = 5, f = 6 } for k, v in pairs( list ) do print( "key: " .. k .. " value: " .. v ) list[ k ] = nil list[ "some key" ] = nil end I get an invalid key for 'next' error everytime. But interestingly enough, merely change "some key" to "some non-existant key" and it doesn't crash. I have not been able to reproduce a crash where setting an existant key caused an error (yet?). Jack Wim Couwenberg wrote: Is this 'official'?Yes, I think. :-) At least the manual only states that assigning to a *non-existent* key in a table results in undefined behaviour during traversal. (See the entry for `next'). Assigning nil to *any* key (existing or not) is also OK, though I'm not sure if tbis is `official' or only documented by ltable.c ... :-) -- Wim __________________________________ Do you Yahoo!? Vote for the stars of Yahoo!'s next ad campaign! http://advision.webevents.yahoo.com/yahoo/votelifeengine/ |