Loop

A loop specifies a block of code that will run repetitively until a halting condition is encountered. For example:

    let mut arr = array![];

    // Same as ~ while (i < 10) arr.append(i++);
    let mut i: u32 = 0;
    let limit = 10;
    loop {
        if i == limit {
            break;
        };

        arr.append(i);

        i += 1;
    };

A while loop allows you to specify a condition that must be true for the loop to continue.

    let mut arr = array![];

    let mut i: u32 = 0;
    while (i < 10) {
        arr.append(i);
        i += 1;
    };
Last change: 2024-02-15, commit: 095ad1c