Loop

A loop line executes a one or more lines until condition is false. The condition is a boolean variable, a function returning a boolean value or an expression resulting in a boolean value.

Parts

A loop consists of an optional initializer, a condition, an optional increment and one or more lines.

  • Initializer
  • Condition
  • Increment
  • Body

Initializer

The initializer is a line executed before the condition is evaluated the first time. It is usually used to initilize a counting variable.

Condition

The condition is evaluated before each time the body is executed. If evaluated to true, the body is executed. If false, execution continues after the loop. The condition can be a boolean variable, a function returning a boolean value or an expression resulting in a boolean value.

Increment

The increment is a line executed after each time the body is executed. It is usually used to increment the counting variable initialized in the initializer.

Body

The body of the loop is one or more lines.