class CSTool {
public static function convert <T1,T2>(from:T1,to:T2) {
//I want to create T2 instance here? how?
}
}
thanks Gama11 ,here is my code ,but it’s wrong how to fixed?
import haxe.Constraints;
class CSTool {
public static function convert<T1, T2>(from:T1) {
var t:T2=make();
}
@:generic
static function make<T:Constructible<Void->Void>>():T {
return new T();
}
}
}
You need to constrain T2
, not add some additional method for it.
can you give a example?
I think he means something like:
public static function convert<T1, T2:Constructible<Void->Void>>(from:T1) {