Skip to content

Commit e7d1a29

Browse files
authored
Add continue keyword documentation (#855)
## Changes Adds documentation for the `continue` keyword. (does creator docs support the language mode `luau`, right now the sample is `lua`, as this has syntax highlighting for continue?) ## Checks By submitting your pull request for review, you agree to the following: - [x] This contribution was created in whole or in part by me, and I have the right to submit it under the terms of this repository's open source licenses. - [x] I understand and agree that this contribution and a record of it are public, maintained indefinitely, and may be redistributed under the terms of this repository's open source licenses. - [x] To the best of my knowledge, all proposed changes are accurate. ---------
1 parent 7f45faa commit e7d1a29

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

content/en-us/luau/control-structures.md

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,9 +252,11 @@ World f
252252
]]
253253
```
254254

255+
## Control Keywords
256+
255257
### Breaking Loops
256258

257-
To force a loop to end, use the `break` command. The following code sample shows how to break an infinite `while``do` loop.
259+
To force a loop to end, use the `break` keyword. The following code sample shows how to break an infinite `while``do` loop.
258260

259261
```lua
260262
local secondsElapsed = 0
@@ -281,3 +283,19 @@ print("Five seconds elapsed. Time to move on!")
281283
Five seconds elapsed. Time to move on!
282284
]]
283285
```
286+
287+
### Continuing Loops
288+
289+
To force a loop to iterate and start again, use the `continue` keyword. A `for` loop will iterate the counter; `while` and `repeat``until` will check the loop condition before continuing. The following code sample gets all children of an `Class.Instance` of a specific `Class.Instance.ClassName|ClassName`.
290+
291+
```lua
292+
local function GetChildrenOfClass(parent: Instance, className: string): {Instance}
293+
local children = {}
294+
for _, child in parent:GetChildren() do
295+
if child.ClassName ~= className then continue end -- Iterates the loop
296+
table.insert(children, child)
297+
end
298+
299+
return children
300+
end
301+
```

0 commit comments

Comments
 (0)