Monkey Documentation

Keyword Self

Object's own reference.

Syntax

Self

Description

The Self keyword provides a way for a method to access the object it belongs to.

See also

Super | Method
Language reference

Example

An object which passes a reference to itself to an outside function. In this case, the Speak method passes Self as the first parameter of the DrawSpeechBubble function.

Class Person

    Field x:Inty:Int

    Method Speak (text:String)
        DrawSpeechBubble (Selftext)
    End

End

Function DrawSpeechBubble (p:Personsay:String)
    DrawText sayp.xp.y
End