Skip to main content

control-flow

Control flow

if / else

Conditional expressions in Typed R behave like in standard R, with additional type safety.

if (4 == 4) {
print("It works!")
}

The type system ensures that:

  • conditions evaluate to boolean values,
  • all branches of a conditional expression are type-compatible when required.

This prevents common errors where different branches return incompatible types.


for / while

Loop constructs such as for and while follow R semantics, while benefiting from type checking:

  • loop variables have well-defined types,
  • operations inside loops are checked for consistency.

This makes iterative algorithms more robust without changing their familiar structure.