Keyword Self - leonard-thieu/monkey GitHub Wiki

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

Examples

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:Int, y:Int

    Method Speak (text:String)
        DrawSpeechBubble (Self, text)
    End

End

Function DrawSpeechBubble (p:Person, say:String)
    DrawText say, p.x, p.y
End