breakWith: Difference between revisions
Jump to navigation
Jump to search
Lou Montana (talk | contribs) m (Text replacement - " |arma3dev |2.01" to " |arma3 |2.02") |
(Added example) |
||
Line 1: | Line 1: | ||
{{RV|type=command | {{RV|type=command | ||
|arma3 | |game1= arma3 | ||
|2.02 | |version1= 2.02 | ||
|gr1= Program Flow | |gr1= Program Flow | ||
| Skips all loop iterations and returns given value. | |descr= Skips all loop iterations and immediately returns the given value. | ||
| [[breakWith]] return | |s1= [[breakWith]] return | ||
|p1= return: [[Anything]] - Value to be returned when iterations are skipped | |p1= return: [[Anything]] - Value to be returned when iterations are skipped | ||
| [[Anything]] | |r1= [[Anything]] | ||
|x1= | |x1= This loop will stop once {{ic|_i}} reaches 5; the output will be "0", "1", "2", "3", "4" and finally "END". | ||
<code>[[systemChat]] [[call]] { | |||
[[for]] "_i" [[from]] 0 [[to]] 10 [[do]] { | |||
[[if]] (_i == 5) [[then]] { [[breakWith]] "END"; }; | |||
[[systemChat]] [[str]] _i; | |||
}; | |||
};</code> | |||
|seealso= [[continueWith]] [[break]] [[continue]] [[breakOut]] | |seealso= [[continueWith]] [[break]] [[continue]] [[breakOut]] | ||
}} | }} |
Revision as of 17:24, 3 March 2021
Description
- Description:
- Skips all loop iterations and immediately returns the given value.
- Groups:
- Program Flow
Syntax
- Syntax:
- breakWith return
- Parameters:
- return: Anything - Value to be returned when iterations are skipped
- Return Value:
- Anything
Examples
- Example 1:
- This loop will stop once
_i
reaches 5; the output will be "0", "1", "2", "3", "4" and finally "END".systemChat call { for "_i" from 0 to 10 do { if (_i == 5) then { breakWith "END"; }; systemChat str _i; }; };
Additional Information
- See also:
- continueWith break continue breakOut
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note