Next: , Previous: , Up: Structs   [Contents][Index]


18.5.17 Methods

Methods in structs can be defined using the method keyword in definitions like this:

method identifier = function_body

where function_body is the body of a function. See Function Declarations.

When invoked, a method gets an implicit last argument which is the struct value whose method is being used.

Methods can refer to the fields of the containing struct type that have been defined before the method itself, by name.