Object is (should be) the proper type to use if you allow any type. 
Casting is of course necessary, because the given parameter must not 
necessarily be of the correct type, so this must be checked and if 
correct the parameter can be casted.
I'm nevertheless not using Object as type, but just leave the type empty 
because there's a problem with interfaces (at least with the Flash 
compiler). It raises an error when you wanna pass an instance casted to 
an interface as parameter that is typed as Object (same problem of 
course with the return type).

Greetings,
Simon

Moses Gunesch wrote:

>Someone is telling me that a function input that is intended to  
>accept more than one datatype (i.e. String & Number) should be typed  
>as :Object to keep it generic.  Like,
>
>public function setColor(colorStringOrNumber:Object):Void
>
>Is :Object the accepted standard, or is it better to just leave it  
>untyped in AS2? (It looks like as3 allows * to be used as an input  
>datatype which will be nice.)
>
>I noticed that using :Object seems to require a little more code  
>within the function - some casting, and occasionally the creation of  
>separate (typed) locals to handle each input type. Seems to be riding  
>the line between correct and confusing anyway, since folks looking at  
>the declaration might be more confused by :Object when the correct  
>inputs are String or Number - so I'm almost more in favor of untyped.
>
>If this is just a code-purist thing I'd rather leave it dirty because  
>I actually think it is more clear to leave it untyped, but if there  
>really is some standard to use :Object I would like to uphold it.
>
>Best way to go? Thanks,
>
>Moses
>
>_______________________________________________
>osflash mailing list
>[email protected]
>http://osflash.org/mailman/listinfo/osflash_osflash.org
>
>
>  
>

-- 
Simon Wacker
www.simonwacker.com
www.as2lib.org
www.hq-heilbronn.de
www.flik-flak.de


_______________________________________________
osflash mailing list
[email protected]
http://osflash.org/mailman/listinfo/osflash_osflash.org

Reply via email to