I saw a method in Action script that has a return type of *
public function f(s:String):*
what does this [*] means ?
I saw a method in Action script that has a return type of *
public function f(s:String):*
what does this [*] means ?
The *
symbol means "untyped", meaning that the type can be anything (and that the value can be undefined
). Using the asterisk has the same effect as not specifying the type at all, but it's good form to use it in order to be explicit about your intention. See the language reference for more info.
That answer is not 100% correct. There is no "untyped" and there is only a small difference between * and Object, because one could argue that Object means untyped as well since every type extends from Object. However * implies the undefined value and Object not. A big difference! This is useful for dynamic languages because this means a property of an Object can be undefined which is different from defined and null.
So for instance y is undefined in { x: null } and x is defined but without a value. And you can make use of that:
var yesNoMaybe: *;
yesNoMaybe = true;
yesNoMaybe = false;
yesNoMaybe = undefined;