Lua Programming/interpolation
Appearance
Variable names
[edit | edit source]There is no default support for automatic interpolation of variables names being used as placeholders within a string. However, interpolation can be emulated by using the [string.gsub] function:
mystring = string.gsub("Mary had a X lamb.", "X", "little") print mystring
Literal characters
[edit | edit source]Interpolation of literal character escape sequences does occur within a string:
print "Mary had a \n lamb" -- The \n is interpreted as an escape sequence for a newline
Bold text