for (C-style)
C for. Emits while plus a trailing increment. Semicolons separate clauses.
Syntax
Section titled “Syntax”for (int i = 0; i < n; i++) {}Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
init | stmt | Runs once. |
cond | bool | Checked every iteration. |
step | expr | Usually i++. |
Return value
Section titled “Return value”None.
Luau emit
Section titled “Luau emit”local i = 0 / while i < n do / i += 1
Description
Section titled “Description”Range-for is a different form: for (T name in collection). Do not mix it with the C-style semicolons.
Example
Section titled “Example”for (int i = 0; i < 10; i++) { post("Count: " .: i);}Emits:
local i = 0while i < 10 do print("Count: " .. i) i += 1end