tostring()

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

Overview

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().

Syntax

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.

Example

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

-- OUTPUT: Display Object: table: 0x19a21df0