print()

Type Function
Library (globals)
Return value none
Revision Release 2022.3683
Keywords print, write, console
See also io.write()

Overview

Receives any number of arguments and prints their values to stdout in the Corona Simulator Console, Xcode, ADB, etc. print() is not intended for formatted output, but rather as a quick way to show a value, typically for debugging. For formatted output, use string.format.

Gotchas

If you are concatenating potentially nil values for output, convert them to strings using the tostring() function:

local nilValue = nil
print( "Value: " .. tostring(nilValue) )

Syntax

print( [...] )
... (optional)

Number or String. The text to output to stdout (generally the Corona Simulator Console). This function will append a newline character (\n) to the end of the final output string.

Console Highlighting

In the Corona Simulator Console, a string output via print() can be highlighted as a "warning" or "error" by prefixing it with WARNING: or ERROR: respectively. For example:

print( "WARNING: " .. "This is a warning!" )
print( "ERROR: " .. "This is an error!" )

WARNING: This is a warning!

ERROR: This is an error!

Example

print( "Hello world!" )

-- OUTPUT: Hello world!