i have scenario need pass dynamic operators loadstring
. found , don't understand.
please see following output:
> = '3' > b = '7' > operator = '+' > loadstring("return a" .. operator .. "b")() 10.0 -- why decimal point. > loadstring("return 3" .. operator .. 7)() 10 -- 1 not?
can explain what's going on inside loadstring
since thought should same result?
the manual says arithmetic operators applied strings:
if both operands numbers or strings can converted numbers (see §3.4.3), converted floats
perhaps want
loadstring("return " .. .. operator .. b)()
instead of
loadstring("return a" .. operator .. "b")()
Comments
Post a Comment