ensure - brombres/Rogue GitHub Wiki

Syntax

ensure<<variable>>(optional-args)

local a : SomeType
...
ensure<<a>>(x)  # equivalent to: if (not a) a = SomeType(x)

local list : SomeType[]
...
ensure<<list>>  # if no args are given then empty args (`()`) are implied.

Description

ensure is a templated command that creates and assigns a new object if the given reference variable is null or zero. It distills a common boilerplate pattern into a succinct statement.

See Also

⚠️ **GitHub.com Fallback** ⚠️