Repeating Operations
- Updated2023-02-17
- 2 minute(s) read
Repeating Operations
When building an application, you may need to repeat code a set number of times or until a specified condition is met. For example, you may have a section of code that you know you want to run three times. You may want your code to keep running until a user clicks a stop button. You can use loops to do this.
Types of Loops
You can use the following loops to repeat code in G Dataflow: a For Loop and a While Loop.
| Loop | Behavior | Example | Diagram |
|---|---|---|---|
| For Loop | Repeats the code inside the loop for a set number of iterations. | Generate five random numbers between 1 and 10. |
|
| While Loop | Repeats the code inside the loop until a specified condition is met. | Continue rolling a die until the value of the die is 6. |
|
Related Information
- Repeating Operations until a Condition Occurs
- Repeating Operations a Set Number of Times
- Repeating Operations Once for Every Element in an Array
- While Loop
- For Loop
- Loop Timing
Loop timing refers to how long a loop takes to execute a single iteration. The amount and type of code a loop contains affects its execution speed.