Skip to content

Latest commit

 

History

History
34 lines (26 loc) · 678 Bytes

File metadata and controls

34 lines (26 loc) · 678 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.