Keyboard shortcuts

Press ← or → to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Strings

Strings are written with single or double quotes:

a = 'hello'
b = "world"
println(a .. ' ' .. b)

Escape sequences

SequenceResult
\nnewline
\ttab
\rcarriage return
\\backslash
\'single quote
\"double quote

Any other backslash sequence is kept as written. Because \t and \n are escapes, write Windows paths with forward slashes or doubled backslashes ('C:\\temp').

println('it\'s')
println("say \"hi\"\nbye")

Joining

.. joins values. Integers are printed as-is and floats with six decimals:

println('total: ' .. 2.5)   # total: 2.500000

String manipulation

The standard library has strlen, substr, strfind, strcase, trim and the conversions str2int, int2str, str2float, float2str. See Standard Library.

Comparing

==, < and friends compare two strings character by character. Comparing a string to a number treats the string as 0.