logo
Spark Docs
logo
Spark Docs
DocumentationCore ConceptsLoops

Loops

Understand how loops work in Spark, how to repeat actions using conditions.

Loop Keyword

The loop keyword is used to repeatedly execute a block of code as long as a given condition remains true. Spark only supports conditional loops, making execution predictable and easy to understand.

let counter 1

# loop
loop counter <= 5 {
  print counter
  counter counter + 1
}