COMMUNITY

How to write generics in extern class?

(Mr Zhan) #1

how to write generics in extern class?

package;


extern class TestJs 
{

	 @:generic public static function GetComponent<T>() : T;
	
}

class Main {
	static function main() {
		var s:String = TestJs.GetComponent<String>();//it's error? how to write like C# here?
	}
}
0 Likes

(Jens Fischer) #2

Haxe’s grammar does not support explicit type parameters in function calls (except for constructors).

0 Likes