What does the "->" mean?

  • Good day everyone!

    I'm currently doing the Tutorial of HaxeFlixel (I'm currently on Enemis and Basic AI).

    I would really appreciate it if anyone can explain to me what does "->" mean.

    An example of the use would be like the one below.

     class FSM
          public var activeState:Void->Void;
          public function new(?InitState:Void->Void):Void
              activeState = InitState;
          public function update():Void
              if (activeState != null)

    Thanks in advance.

  • It's used for functions. Check this doc: Function Type
    Void->Void means a function with no argument and returns Void
    You can pass a such function to the constructor like this:

    function initState():Void {
        // init stuff
    var fsm = new FSM(initState);

    In this example below, createPlayer is a String->Int->Player

    function createPlayer(name:String, health:Int):Player {
        //create player

  • Thanks for the doc! Much appreciated!

Log in to reply

Looks like your connection to HaxeFlixel was lost, please wait while we try to reconnect.