views:

43

answers:

1

I have the following bit of syntax:

Void -> Void
//in context example
private var _onClickEvents : List < Void -> Void > ;

which seems to be accepted as a type definition, the same as Bool or TextField. I presume it has similar use to how Haskell defines function type signatures?

+3  A: 

static public function sayHello() : String { return "hi!"; }

has type: Void -> String

The last element is the type the function returns; previous elements are the types of the arguments.

static public function factory(generator : String -> String -> String, times : Int) : Int -> String;

Consider this function which takes as arguments one function (with 2 arguments and that returns a string) and an integer value and returns a function.

Its type is: (String -> String -> String) -> Int -> (Int -> String)

If you are in doubt what the correct type is, you can always use the type command. It is only used at compile time and returns in the console the type of its argument:

type(factory);

Should print what I wrote above.

Franco Ponticelli