Flash function overload in Haxe

I'm having trouble figuring out how to overload a function in Flash using Haxe. I know that Flash does not allow overloading, but can accept function parameters without an declared type, but I'm not sure how to replicate this trick in Haxe.

EDIT: since this is not possible, are there any known tricks that can be used to overcome this limitation?

+3
source share
3 answers

The Haxe website provides an example of how to achieve this here: http://old.haxe.org/ref/optional_args

I don't think haxe supports true method overloading ... although not sure. Good luck

+4

, , AS3, . , . .

public function bar(param1:Dynamic, param2:Dynamic):Dynamic
{
  if(Std.is(param1, Float) && Std.is(param2, Float))
    doStuffWithFloats(param1, param2);
  else if(Std.is(param1, String) && Std.is(param2, String))
    doStuffWithStrings(param1, param2);
}
0

Source: https://habr.com/ru/post/1744710/


All Articles