NOTE: This invite-only release of SunSed Alpha is for testing purposes and in no way represents the final quality of the product — join the waitlist (~wait time: 2 weeks). SunSed release date is on March 11, 2022.

Loops

Loops are one of the best ways to avoid repetition in your code. Instead of having to write similar lines of codes over and over, loops allow you to execute a block of code multiple times, each time using a different value (most often using arrays).

Instead of repeating yourself

::h3 "Users' ID List"
:: $users[0]
:: $users[1]
:: $users[2]
:: $users[3]
:: $users[4]
:: $users[5]
:: $users[6]
:: $users[7]
:: $users[8]
:: $users[9]

You can do the following using loops and get the exact same result.

::h3 "Users' ID List"
FOREACH($users AS $user) {
    :: $user
}

SunSed has 4 looping statements (FOR, FOREACH, WHILE, DO WHILE, each with its unique benefits optimal for different needs and requirements.

Copyright © SunSed LLC 2013-2021 All rights reserved.