tostring lua
The tostring
function in Lua is used to convert a value to a string. It takes one argument and returns a string representation of that argument. If the argument is already a string, it returns the argument unchanged. If the argument is a number, it returns a string representing that number. If the argument is a table, tostring
returns a string in the format "table: address"
, where address
is the memory address of the table.
Here's an example:
local value1 = 10
local value2 = "hello"
local value3 = {1, 2, 3}
print(tostring(value1)) -- Output: "10"
print(tostring(value2)) -- Output: "hello"
print(tostring(value3)) -- Output: "table: address"