Declares the beginning of a class method.
Method Identifier: ReturnType ( Parameters ) [ Property ] [ Abstract ] [ Final ]~n
Statements...
End [ Method ]
The Method keyword begins the declaration of a class method.
Please see the Methods section of the monkey language reference for more information on methods.
End | Class | Property | Abstract | Final
Language reference (Classes)
Language reference (Methods)
An example of methods as statements.
Class
GameObject
Field
x
:
Float
Field
y
:
Float
Method
PrintX
()
Print
x
End
Method
PrintY
()
Print
y
End
End
Local
g
:
GameObject
=
New
GameObject
p.x
=
100
p.y
=
200
' Accessing method...
p.PrintX
p.PrintY
Strict mode version of above GameObject class. (Note use of Void return type.)
Class
GameObject
Field
x
:
Float
Field
y
:
Float
Method
PrintX
:
Void
()
Print
x
End
Method
PrintY
:
Void
()
Print
y
End
End
Method returning value of Float type.
Class
GameObject
Method
AddFloats
:
Float
(
value1
:
Float
,
value2
:
Float
)
Return
value1
+
value2
End
End
Local
g
:
GameObject
=
New
GameObject
' Accessing method...
Print
g.AddFloats
(
1.5
,
2.0
)