why did I get a decimal point by using loadstring in Lua -


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

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -