-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed as not planned
Labels
Milestone
Description
While going through math code, I see many functions that's usage could be simplified by using generics.
this will simplify code like this:
var a, b int = 5, 10
var max int
max = int(math.Max(float64(a), float64(b)))to be just
var a, b int = 5, 10
var max int
max = math.Max(a, b)because Max declaration could become
func Max[T number](x, y T) T {...}what the number should be needs to be discussed. My proposal is to make it
type number interface {
~int | ~uint | ~float32 | ~float64
}