Lua: attempt to perform arithmetic on a string value

后端 未结 1 894
南旧
南旧 2021-01-12 14:41

I\'m trying to add a string to a returned value in lua:

local function func(str)
   return (str+\"_something\")
end

print(func(\"ABC\"))

a

相关标签:
1条回答
  • 2021-01-12 15:01

    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

    0 讨论(0)
提交回复
热议问题