you could try this: private function myMethod( i:Object ):Void
On 6/15/06, Adrian Park <[EMAIL PROTECTED]> wrote:
Hi List, What's the neatest way of accepting a single parameter with 2 possible types into a method and then working out what type of parameter has been passed? e.g. in pseudo code private function myMethod( i:Number/String ):Void { if ( i is a String ) { // do this } else if ( i is a Number ) { // do this } } I can think of several alternatives : - passing a generic object which contains the property and then using typeof on that property - calling 2 different methods but, in this case, it just makes sense to be one since it's doing the same thing with either parameter (retrieving a bit of data from an Array which may be identified using a numerical id or a String ID) - limiting my method to accepting a String only and then defining a second method that returns the correspoding String identifier given a numerical identifier All of the ways I can think of seem dirty. Is there a nice clean way or is it wrong to expect the method to accept one parameter of different types? Thanks in advance, Adrian P. _______________________________________________ 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
-- Daniel Cascais Tel: +56 (0)2 4589495 Cel: +56 (0)9 9417355 _______________________________________________ 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