min<T:(Int,Float)>
means T
should be both Int
and Float
. See the constraints section of Haxe Manual.
Given Int
can be converted to Float
implicitly, you can safely remove the constraint of Int
. i.e. the following will works:
class Test {
public static function min<T:Float>(t:T, t2:T):T { return t < t2 ? t : t2; }
static function main() {
var a = min(1.1,2.2); //ok
$type(a); //Float
trace(a); //1.1
var b = min(1,2); //ok
$type(b); //Int
trace(b); //1
}
}