Scopes

In GoMelan some control structures imply different scopes.

Example for if

fn main() -> Bool
{
    var: Bool = true;

    if (var) {
        inScope: String = "I'm in this scope only"; // inScope will only lie in this condition
        var = false; // var from outter scope will be modified
    }
    
    // inScope cannot be accessed here

    return var; // Returns false
}

The control structure for is also subject to this scope system.

Last updated