while loop isn’t used much. It’s not used in FP at all, and it’s rarely used in OOP, so I’ll only cover it briefly.
As with other languages, it’s used along with
var (mutable) fields. However, unlike other languages, we don’t really use method like
while condition do statement(a) statement(b)
var x = 1 while x < 5 do println(x) x += 1
Can optionally add
end at the end:
var x = 1 while x < 5 do println(x) x += 1 end while