O'Reilly logo

haXe 2 by Benjamin Dasnois

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Function's type

Functions are typed too. That's good for two reasons: you can pass a function as a parameter to another function, and you can also store typed functions in a variable!

Expressing a function's type

All functions in haXe are typed, so for example, when you write:

public function outputString(st : String) : Void;

we know that the outputString function takes one parameter of type String and returns Void (that actually means that it does not return any object). This is represented as the following type:

String->Void

Now, imagine the following function:

public function sumAndCeil(a : Float, b : Int) : Int

Its type is:

Float->Int->Int

Ok, this was the easy part.

Functions using functions

As mentioned earlier, a function can be given as an ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required