> 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 > } > } >
Funny, I just added the optional arguments to haXe and you could do the following : function myMethod( ?i : Int, ?s : String ) : Void { if( i != null ) { // Int argument } else if( s != null ) { // String argument } } myMethod(12345); // same as myMethod(12345,null); myMethod("hello"); // same as myMethod(null,"hello"); Nicolas _______________________________________________ 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