RE: [Flashcoders] why are my class property's strong typingbeingignored?

2006-11-16 Thread Steven Sacks | BLITZ
A winky emoticon denotes sarcasm or a joke.

I'm glad that somebody was able to locate your problem, though.  I
figured somewhere you were using a loosely typed variable so the
compiler wasn't complaining.

Here's a fun one.

someFileName:String = something.swf;
extension:String = someFileName.split(.).pop();

This generates a compiler error.  The compiler doesn't know that the
type is String because the intrinsic class Array specifies Object as the
return type of pop().

The solution:

someFileName:String = something.swf;
extension:String = String(someFileName.split(.).pop());

The lesson here is that if you don't get compiler errors with strict
typing, you're either using bracket access to dynamically set variables
in which case the compiler can't know, or you loose typed something
elsewhere.  

Of course, all of this goes away when you start using AS3/VM2 which
generates errors for type mismatching which can be handled using things
like try catch finally, etc.
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


Re: [Flashcoders] why are my class property's strong typingbeingignored?

2006-11-16 Thread Rich Rodecker


A winky emoticon denotes sarcasm or a joke.




right, i got that part, which is why you got a smiley in return.  a smiley
indicates a good vibe.

the reasoning for making Object the return type for pop() is obvious...but i
se what you mean by your example.


On 11/16/06, Steven Sacks | BLITZ [EMAIL PROTECTED] wrote:


A winky emoticon denotes sarcasm or a joke.

I'm glad that somebody was able to locate your problem, though.  I
figured somewhere you were using a loosely typed variable so the
compiler wasn't complaining.

Here's a fun one.

someFileName:String = something.swf;
extension:String = someFileName.split(.).pop();

This generates a compiler error.  The compiler doesn't know that the
type is String because the intrinsic class Array specifies Object as the
return type of pop().

The solution:

someFileName:String = something.swf;
extension:String = String(someFileName.split(.).pop());

The lesson here is that if you don't get compiler errors with strict
typing, you're either using bracket access to dynamically set variables
in which case the compiler can't know, or you loose typed something
elsewhere.

Of course, all of this goes away when you start using AS3/VM2 which
generates errors for type mismatching which can be handled using things
like try catch finally, etc.
___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com


___
Flashcoders@chattyfig.figleaf.com
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders

Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com