according to the manual:
A += 2 -- EQUIVALENT TO: A = A + 2 // note that the LHS appears twice, so for TBL[FN()]+=1, FN() will be called twice. |
ok, let's test it:
function fn() print("in function") return 1 end f={ 10 } print("f[1] is "..f[1]) f[fn()]+=1 print("f[1] is "..f[1]) |
the function fn is only called once!
P#134947 2023-09-27 09:42
[Please log in to post a comment]