Open utterances-bot opened 5 years ago
very nice with Borat accent
Doesn't seem to work with @:using
though.
To elaborate: yes, adding static methods with @:using
seems pointless, but it helps with enums:
@:using(MyEnum.MyEnumExt) enum MyEnum {A; B;}
class MyEnumExt {
public static function default(_: Enum<MyEnum>): MyEnum return A;
}
It works with using MyEnum.MyEnumExt
, but not with metadata.
Adding static methods to existing classes - Other - Haxe programming language cookbook
Haxe allows you to add static methods to existing classes (eg. Math) via the static extensions feature. The secret sauce is to specify the first parameter of the extension as Class where X is the class you want to add static methods to (eg. Math), and to make the method public.
https://code.haxe.org/category/other/adding-static-methods-to-existing-classes.html