From 32fd23e41668e0bf845807485e9697d1757acd65 Mon Sep 17 00:00:00 2001 From: James <85808999+TheGreatSageEqualToHeaven@users.noreply.github.com> Date: Thu, 15 Feb 2024 18:25:03 +0000 Subject: [PATCH] Update syntax-if-statements-initializers.md --- docs/syntax-if-statements-initializers.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/syntax-if-statements-initializers.md b/docs/syntax-if-statements-initializers.md index e1f0026..344c521 100644 --- a/docs/syntax-if-statements-initializers.md +++ b/docs/syntax-if-statements-initializers.md @@ -67,6 +67,26 @@ end `Output: Hello World, from Luau!` +If statement initializers are also allowed in `elseif` conditions. + +Example: + +```lua +local a = false +local function foo() + local b = a + a = true + return b +end + +if local a = foo() then +elseif local b = foo() then + print(b) +end +``` + +`Output: true` + # Drawbacks Parser recovery may be more fragile due to the `local` keyword.