Skip to content
IsaacShelton edited this page Mar 21, 2022 · 1 revision

this

this is used as the name of the first argument of a function to turn it into a method.

func getFullname(this *Person) String {
    return this.firstname + " " + this.lastname
}

Domain Methods

Methods declared within a struct's domain don't take an initial parameter, so this is not used.

struct Person (firstname, lastname String) {
    func swapFirstnameLastname() void {
        tmp String = this.firstname
        this.fistname = this.lastname
        this.lastname = tmp
    }
}
Clone this wiki locally