Skip to content

Latest commit

 

History

History
36 lines (27 loc) · 734 Bytes

File metadata and controls

36 lines (27 loc) · 734 Bytes

if statement

Syntax
IfStatement :
   if Expression{    (Statement | Expression)+
   }
   (else {
   (Statement | Expression)+
   })?\

Example:

contract Foo {

    pub fn bar(val: u256) -> u256 {
        if val > 5 {
            return 1
        } else {
            return 2
        }
    }
}

The if statement is used for conditional execution.