Studio Bugs: if-then-else expressions not behaving as expected
The if-then-else expression recently added has end completion and indentation issues when either the ‘a’ or ‘b’ in if a then b else c is a function.
Repro
In studio, try and type any if-then-else expression that contains a function in either the ‘a’ or ‘b’ part of the expression. Then press enter to start new line and it will either attempt to auto complete or go back an indentation.
Expected behavior
It should behave in the same way the old syntax behaved. The same expression using and-or has no issues.
local str = workspace:FindFirstChild("Part") and "found" or "nope"
The issue is that this is a bug report and workarounds don’t solve bugs. This is a new luau feature and is intended to do that job. The old way was merely a side effect of Lua’s logic behavior. It is better to use things which have been purpose built as there will be better long term support and optimization.