lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


To my knowledge, it is in theory undefined behavior, so shall not be done.
In practice, an iterator variable acts as regular local variables that
could be assigned to.
But this *does not* affect the loop, as if the variable holds *a copy*
of the real iteration state.

Examples:
> for i=1,3 do i=i*2; print(i) end
2
4
6
> for k,v in pairs(table) do k=k..k; print(k,v) end
maxnmaxn        function: 003CD800
packpack        function: 0041DDA0
concatconcat    function: 0041DBA0
insertinsert    function: 0041D820
sortsort        function: 0041E520
removeremove    function: 0041D950
unpackunpack    function: 0041DE80