What is tostring() in Lua?
In Lua, you can convert a number to a string using the tostring() function.
Syntax
tostring(number)
Parameters
This function requires a number as a mandatory parameter.
Return value
This function will return the number as a string value.
Code
In this example, we will convert two different numbers and we will see the differences in the output.
mynumber = 10newstring = tostring(mynumber)print(mynumber, " is a ", type(newstring))mynumber2 = 10.0newstring2 = tostring(mynumber2)print(mynumber2, " is a ", type(newstring2))
Expected output
10 is a string
10.0 is a string