return statement

Syntax
ReturnStatement :
   return Expression?

The return statement is denoted with the keyword return. A return statement leaves the current function call with a return value which is either the value of the evaluated expression (if present) or () (unit type) if return is not followed by an expression explicitly.

An example of a return statement without explicit use of an expression:

contract Foo {
    fn transfer(self, to: address, value: u256) {
        if not self.in_whitelist(to) {
            return
        }
    }

    fn in_whitelist(self, to: address) -> bool {
        // revert used as placeholder for actual logic
        revert
    }
}

The above can also be written in a slightly more verbose form:

contract Foo {
    fn transfer(self, to: address, value: u256) -> () {
        if not self.in_whitelist(to) {
            return ()
        }
    }

    fn in_whitelist(self, to: address) -> bool {
        // revert used as placeholder for actual logic
        revert
    }
}