Skip to main content

String Interpolation

String interpolation is a simple alternative syntax to concatenation that also implies tostring.

Concatenation
pluto
local label = { en = "meaning of life" }
local data = nil
print("The " .. label.en .. " is " .. tostring(data)) --> The meaning of life is nil
String Interpolation
pluto
local label = { en = "meaning of life" }
local data = nil
print($"The {label.en} is {data}") --> The meaning of life is nil

As you can see, you declare a string interpolated by prefixing it with the "$" symbol. Brackets can contain any expression. The result of expressions will be passed to tostring.