-
-
Notifications
You must be signed in to change notification settings - Fork 9
this
IsaacShelton edited this page Mar 21, 2022
·
1 revision
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
}
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
}
}