Functions

Wu functions are expressions, but can also be declared using the same notation as struct. For example we can declare functions like this:

add_two: fun(a: int) {
    a += 2
}

The following is just as valid, but more ugly:

add_two := fun(a: int) {
    a += 2
}

They are the exact same behind the scenes. No difference at all.

Functions return the last expression in their body implicitly(like in Rust) like so:

ten: fun {
    10
}

print(ten()) # 10

Why have parentheses if they're empty anyways?

You are still able to use explicit returns:

twenty: fun {
    return ten() + ten()
}

Of course, as we're dealing with a decent language, higher order functions are a thing:

Now for something vaguely interesting. Splats are basically a catchall parameter, that binds as many arguments you throw at it into an array:

Of course we can type the splats:

Last updated