String, Boolean, Number, int, uint are all Objects...
var a:String = "";
trace(a is Object); //true
var b:uint;
trace(b is Object); //true
I find * useful when I don't want to explicitly type cast:
function a():Object {
return "hi";
}
var b:String = a(); //compile time error
function a():* {
return "hi";
}
var b:String = a(); //this is legal
H
On Sat, Aug 9, 2008 at 6:12 PM, Claus Wahlers <[EMAIL PROTECTED]> wrote:
> Also, mind this:
>
> var a:*;
> trace(a);
> // undefined
>
> var b:Object;
> trace(b);
> // null
>
> An Object can't be undefined.
>
> Cheers,
> Claus.
>
>
> Ian Thomas wrote:
>
> '*' means "discard type checking"
>> 'Object' means 'treat it as type Object'
>>
>> If you have functions:
>>
>> public function getThing():*
>> {
>> return new Bucket();
>> }
>>
>> public function getAnotherThing():Object
>> {
>> return new Bucket();
>> }
>>
>> then this will compile:
>>
>> var someVar:Bucket=getThing(); // Ignores type checking
>>
>> And this won't:
>>
>> var someVar:Bucket=getAnotherThing(); // Tries to assign Object to
>> Bucket. Compile-time error.
>>
>> (while this will - with a cast:
>>
>> var someVar:Bucket=getAnotherThing() as Bucket;
>>
>> )
>>
>> HTH,
>> Ian
>>
>> On Fri, Aug 8, 2008 at 11:07 PM, Dave Segal <[EMAIL PROTECTED]> wrote:
>>
>>> What is the difference between typing an instance as "*" and typing it as
>>> "Object"?
>>>
>>
>
> _______________________________________________
> Flashcoders mailing list
> [email protected]
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
_______________________________________________
Flashcoders mailing list
[email protected]
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders