How to make an extension on all numeric types in Swift?
cf. Numeric protocol
extension Numeric { func addOne() -> Self { return self + 1 } } 1.addOne() 2.4.addOne()
Add where Self: Comparable to get the comparable feature
where Self: Comparable