optional<T>
optional<T>
Section titled “optional<T>”A value that may be missing. Emits Luau T?.
Syntax
Section titled “Syntax”optional<T> name = null;Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
T | type | Inner type. |
Return value
Section titled “Return value”T or null.
Luau emit
Section titled “Luau emit”T?
Description
Section titled “Description”Not std::optional with .value(). Test with != null or guard.
Example
Section titled “Example”optional<Player> target = null;Emits:
local target: Player? = nil