Skip to main content

Default Arguments

During a function declaration, parameters can now declare their own default value, which must be a compile-time constant.

Example Code
local function write(text = "No text provided.")    print(text)endwrite()         --> "No text provided."write("Hello!") --> "Hello!"
This code is semantically equal.
local function write(text)    text ??= "No text provided."    print(text)endwrite()         --> "No text provided."write("Hello!") --> "Hello!"