Loops
for loop
for loopIn Hades, there is no C-style count-controlled loop, but only a foreach loop which iterates over an array.
Example
with math fixed from std:math
with console from std:io
for(var i int in range(0,10) /*'range' returns an array with the number 0 to 10*/)
console.out(i)
end
let fruits string[] = {"Apple", "Banana", "Mango", "Kiwi"}
for(var fruit in fruits)
console.out("{} is very healthy".format(fruit))
endIf you don't need a variable, you can use an underscore instead of naming a variable or variable declaration.
for(_ in range(0,10))
console.out("")
endRange also has a shorthand: ...
Example
while loop
while loopThe while loop pretty much works like you'd expect. It loops as long as a given condition evaluates to true.
Example
stop and skip statements
stop and skip statementsThe stop statement stops a loop.
Example
The skip statement skips over the current state of a loop. In while loops, this just skips execution of the code after the skip statement. In a for loop, this statement also skips to the next value of an array.
Example
Last updated