I'm trying to add a string to a returned value in lua:
local function func(str)
return (str+"_something")
end
print(func("ABC"))
and I'm getting an error:
"attempt to perform arithmetic on local 'str' (a string value)"
or this error (in my original program):
@user_script:1: user_script:1: attempt to perform arithmetic on a string value
I tried to use tosring(str)+"_something" but didn't help...
so how to Concatenate a string in Lua ?
see "Concatenation" in this link: http://lua-users.org/wiki/StringsTutorial
The solution is to use the ..
, as in example:
local function func(str)
return (str.." WORLD")
end
print(func("HELLO"))
that's should return:
HELLO WORLD
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With