- Home /
Difference between Function and function() Types
Hey. this related to javascript of course, but what is the difference of those 2 types?
Function and function()
? Thanks
Comment
Best Answer
Answer by Eric5h5 · Mar 29, 2013 at 12:15 AM
Function matches any kind of function, but function() matches only a particular signature. For example, given these functions:
function Foo (x : int) : float {
return x/2.0;
}
function Bar () {
Debug.Log ("Yo");
}
Then both of these will work:
var foo : Function = Foo;
var foo2 : function(int):float = Foo;
This, however, will not work:
var bar : function(int):float = Bar;
Because the Bar function doesn't take any arguments and returns void. So it would have to be this instead:
var bar : function():void = Bar;