Issue Description
This is not a severe issue by any means as it is not misleading, especially given that Roblox Studio warns about this syntax.
The page states:
Luau doesn’t offer a direct equivalent to the C# conditional operator,
a ? b : c
. However, the Luau idioma and b or c
offers a close approximation, provided b isn’tfalse
ornil
. For a complete explanation of this idiom, see lua-users wiki. You may need to surround this idiom with parenthesis in some cases.
A proposed new explanation is:
C#'s ternary operator
a ? b : c
can be achieved in Luau usingif a then b else c
. Note that unlike traditionalif
statements, ternary operators in Luau are not closed with theend
keyword. This serves as a superior alternative to thea and b or c
idiom commonly used in traditional Lua because is not subject to the side effects ofb
beingfalse
ornil
. Luau’s implementation also provides a way to chain statements together withelseif
, for example:if a then b elseif c then d else e
is identical toa ? b : (c ? d : e)
Issue Area: Documentation Content
Page URL: Luau and C# Comparison | Roblox Creator Documentation