Question about the scope of repeat-until loop

Hey guys, I found this sentence in the documentation and I wonder what does it mean exactly… Can someone explain it to me?

sentence:

Unlike other languages, the Luau scope of a local variable
declared inside a repeat—until loop includes the condition.

Source:

Im pretty sure this just means that if a variable is changed or defined in a repeat-until loop the condition expression (until) can still recognise changes were made in the loop

1 Like

I actually asked AI about this and this is the response:

in Luau (used in Roblox scripting), when you declare a local variable
inside a repeat—until loop, that variable is still accessible in the condition 
part of the loop (the until condition). This is different from how some other 
programming languages handle variable scope.

Then it showed me this example:

repeat
    local x = 10
    print(x)  -- You can use x here
until x == 10  -- You can also use x here in the condition

Anyway, thanks for trying to help me…

im pretty sure i just said a paraphrased version of what your ai said

OH, ye right, sorry… my bad XD

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.