Functions vs Methods
Monkey Forums/Monkey Programming/Functions vs Methods| 
 | ||
| So, I'll start a few newbie questions from now on.. first: Whats the  difference between Functions and Methods? | 
| 
 | ||
| methods are part of a class, functions are global methods can be overridden by other classes that extend the original class | 
| 
 | ||
| I'm trying to call the method "update" of class Player from OnUpdate, but i got the following error when i run (it builds w/o error):  Monkey Runtimer Error : TypeError: Cannot call method 'm_update' of null  Global player:Player ... Method OnUpdate:Int() player.update() Return 0 End ... Class Player Method update:Void() End Method render:Void() End End If I change Method update:void() to Function update:void() it works, but i can't access class variables. What could be wrong? | 
| 
 | ||
| Try something like [monkeycode] Global player:Player = New Player [/monkeycode] You could also put it in your OnCreate method. [monkeycode] Global player:Player Method OnCreate:VOID() player = New Player End Method [/monkeycode] Probably. | 
| 
 | ||
| I already have player = New Player on "onCreate" method | 
| 
 | ||
| it's strange  Monkey Runtimer Error : TypeError: Cannot call method 'm_update' of null  is cause you are not called [monkeycode]player = New Player[/monkeycode] take a look | 
| 
 | ||
|  @slenkar: methods are part of a class, functions are global  Careful with your terminology there. Global functions are not the same as static functions. Static functions also belong to a class, but they don't require an instance to call them. |