Type Function
Library (globals)
Return value String
Revision Release 2023.3686
Keywords string, types, datatype
See also tonumber()


This API is a useful debug tool for displaying or concatenating nil values. For complete control of how numbers are converted to strings, use string.format().


tostring( e )
e (required)

Any. Item to convert to a string type. If the metatable of e has a __tostring field, this function calls the corresponding value with e as the argument and passes the result of the call as its result.


local rect = display.newRect( 0, 0, 100, 200 )
print( "Display Object: " .. tostring( rect ) )

-- OUTPUT: Display Object: table: 0x19a21df0