Open utterances-bot opened 6 months ago
One thing that would help to let people know is that you can constrain to numeric using Float
, e.g.,
function add<T:Float>(a:T, b:T):T {
return a + b;
}
This will even work with Int
and I can confirm on the hxcpp target at least it does monomorph to a class that uses ints, no float conversion.
Constraints - Haxe - The Cross-platform Toolkit
Haxe is an open source toolkit based on a modern, high level, strictly typed programming language.
https://haxe.org/manual/type-system-type-parameter-constraints.html