# 05 · repeat-scope **演示**:`repeat ... until` 的 `until` 表达式能访问循环体内声明的局部变量。 **运行时**:`lua54`、`luajit`。 **运行**: ```sh .tools/bin/lua54 scripts/run-example.lua examples/06-control-flow-and-truthiness/05-repeat-scope .tools/bin/lua54 scripts/test-example.lua examples/06-control-flow-and-truthiness/05-repeat-scope ``` **预期输出**(lua 5.4.9 / macOS arm64): ```text attempts=2 value=4 ``` **看点**:这是 `while` 做不到的:`while` 的条件在循环体外,看不到循环体局部。 **注意**:`until` 里修改局部变量会影响下一次判断,逻辑要写清。