Skip to content

Latest commit

 

History

History
30 lines (23 loc) · 844 Bytes

File metadata and controls

30 lines (23 loc) · 844 Bytes

while statement

Syntax
WhileStatement :
   while Expression {
   (Statement | Expression)+
   }\

A while loop begins by evaluation the boolean loop conditional expression. If the loop conditional expression evaluates to true, the loop body block executes, then control returns to the loop conditional expression. If the loop conditional expression evaluates to false, the while expression completes.

Example:

contract Foo {

    pub fn bar() -> u256 {
        let mut sum: u256 = 0
        while sum < 10 {
            sum += 1
        }
        return sum
    }
}