Last updated 3 years ago
Was this helpful?
func abs<T>(_ x: T) -> T where T : , T :
abs(-5), // 5 abs(-3.45), // 3.45 abs(Int.min) // โ overflow
โฉ โฉ - abs<T> ๆฏไธๅ generic function๏ผ็บไป้บผๆพๅจ Int ่ฃก้ข๏ผ
Comparable
SignedNumeric