@@ -13,9 +13,9 @@ toc: sections
1313curated : /stdlib/closure_for_groups
1414---
1515
16- Executes the given closure for every unit in this group,
17- removing the units from the group as processed.
18- Return true to continue iteration, false to stop .
16+ Executes the given closure for every unit of the given type.
17+ Stops invoking the closure after * count * units. The underlying enumeration
18+ cannot be aborted, so it still visits every match .
1919
2020** [ Source on GitHub] ( https://github.com/wurstscript/WurstStdlib2/blob/master/wurst/closures/ClosureForGroups.wurst ) **
2121
@@ -72,9 +72,6 @@ Executes the given closure for every unit of the given type.
7272public function forUnitsOfTypeCounted(string unitname, int count, ForGroupCallback c)
7373```
7474
75- Executes the given closure for every unit of the given player.
76- Cancels itself after * count* iterations
77-
7875### forUnitsOfPlayer
7976
8077``` wurst
@@ -106,7 +103,8 @@ public function forUnitsInRectCounted(rect r, int count, ForGroupCallback c)
106103```
107104
108105Executes the given closure for every unit in the given rect.
109- Cancels itself after * count* iterations
106+ Stops invoking the closure after * count* units. The underlying enumeration
107+ cannot be aborted, so it still visits every unit in the rect.
110108
111109### forUnitsInRange
112110
@@ -131,8 +129,9 @@ Executes the given closure for every unit in range of the given position
131129public function forUnitsInRangeCounted(vec2 pos, real radius, int count, ForGroupCallback c)
132130```
133131
134- Executes the given closure for every unit in range of the given position
135- Cancels itself after * count* iterations
132+ Executes the given closure for every unit in range of the given position.
133+ Stops invoking the closure after * count* units. The underlying enumeration
134+ cannot be aborted, so it still visits every unit in range.
136135
137136### forUnitsSelected
138137
@@ -212,7 +211,7 @@ public function forDestructablesInRange(vec2 pos, real range, ForGroupCallbackD
212211```
213212
214213Executes the given closure for all destructables in a rect
215- that incompasses the circle with the range radius at the given position.
214+ that encompasses the circle with the range radius at the given position.
216215
217216### forDestructablesInRange
218217
@@ -221,7 +220,7 @@ public function forDestructablesInRange(vec2 pos, real range, boolexpr filter, F
221220```
222221
223222Executes the given closure for all destructables in a rect
224- that incompasses the circle with the range radius at the given position.
223+ that encompasses the circle with the range radius at the given position.
225224
226225### forDestructablesInRect
227226
@@ -245,7 +244,7 @@ Executes the given closure for all destructables in the given rect
245244public function forNearestDestructable(vec2 pos, real range, ForGroupCallbackD c)
246245```
247246
248- Executes the given closure for the closes destructable in the given rect .
247+ Executes the given closure for the closest destructable in the given range .
249248 If there is no destructable in range, the closure will be run with "null"
250249
251250## Extension Functions
@@ -274,6 +273,10 @@ Executes the given closure for every unit in this group,
274273public function group.forEachFromUntil(ForGroupCallbackUntil cb)
275274```
276275
276+ Executes the given closure for every unit in this group,
277+ removing the units from the group as processed.
278+ Return true to continue iteration, false to stop.
279+
277280### group.forEachInUntil
278281
279282``` wurst
0 commit comments