Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Actionscript variable declared as * (star) type

I saw following statement somewhere -

var someVariable:*;

Why is someVariable declared as * (star) type? What is the use of declaring it this way?

like image 423
nuaavee Avatar asked Nov 05 '10 03:11

nuaavee


1 Answers

The practical difference between * and Object is that * can be undefined whereas Object cannot.

The docs have this to say:

Specifies that a property is untyped. Use of the asterisk symbol for a type annotation is equivalent to using no type annotation. Expressions that read from untyped properties are considered untyped expressions. Use of untyped expressions or properties is recommended in the following circumstances:

  • When you want to defer type checking to runtime. You can use an untyped property or expression to circumvent compile-time type checking in strict mode. Note, however, that runtime type checking of assignment statements occurs whether you use strict mode or not.

  • When you want to store the value undefined in a property. Unlike previous versions of ActionScript, the value undefined is not a member of the Object data type. You must use an untyped property to store the value undefined.

like image 112
Samuel Neff Avatar answered Sep 18 '22 16:09

Samuel Neff