I'm just a beginner of LUA. I don't understand why the value of the object "number" was changed in this body. Thanks in advance if you could answer me.
function square(iteratorMaxCount, number)--how the value of "number" was changed?
currentNumber = number + 1
if currentNumber<=iteratorMaxCount
then
return currentNumber, currentNumber*currentNumber, number
end
end
for i,n ,k in square,3,-1
do
print(i,n,k)
end
this is the solution:
lua.exe iterator.lua
0 0 -1
1 1 0
2 4 1
3 9 2