I am following a tutorial for HaxeFlixel that uses the Haxe language. Now I have no experience with Haxe, but I decided to dare to take this lesson, since I have experience with Java and Haxe, as the language seems strangely similar to Java.
So far, everything went smoothly. However, I came across this piece of code, and I have a few questions:
class FSM { public var activeState:Void->Void; public function new(?InitState:Void->Void):Void { activeState = InitState; } public function update():Void { if (activeState != null) activeState(); } }
Now I understand that this is a class called FSM and has a variable called activeState .
Here are my questions:
What is the type of activeState ? I would understand if there was something like activeState:Void , but what does -> do? Is it used as a pointer? Is it a pointer to void pointing to another void variable?
What does it mean ? before InitState:Void->Void ?
After the if statement, activeState is called as a function using parentheses. However, activeState is a variable, not a function. So what exactly does the if statement do?
One more question:
public var playerPos(default, null):FlxPoint;
I understand that playerPos is an instance of the FlxPoint class, but what do default and null do?
source share