Syntax Lookup

Enter some language construct you want to know more about.

while

This is the while loop.

ReScript supports while loops. While loops execute its body code block while its condition is true.

A mutable binding can control whether a while loop continues.

Example

ReScriptJS Output
let shouldStop = ref(false)

while !shouldStop.contents {
  if Math.random() > 0.3 {
    shouldStop := true
  } else {
    Console.log("Still running")
  }
}

References