Log In  

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

Good catch! The warning is obsolete as of a couple of builds back, when @zep turned += from a macro into a proper assignment operator.

P#134949 2023-09-27 09:52 ( Edited 2023-09-27 09:52)

[Please log in to post a comment]