Do

suggest change

Do-loops are useful when you always want to run a codeblock at least once. A Do-loop will evaluate the condition after executing the codeblock, unlike a while-loop which does it before executing the codeblock.

You can use do-loops in two ways:

Do {
    code_block
} while (condition)
Do {
    code_block
} until (condition)

Real Examples:

$i = 0

Do {
    $i++
    "Number $i"
} while ($i -ne 3)

Do {
    $i++
    "Number $i"
} until ($i -eq 3)

Do-While and Do-Until are antonymous loops. If the code inside the same, the condition will be reversed. The example above illustrates this behaviour.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents