Last active
June 10, 2021 02:54
-
-
Save jeromewu/444bff64c874107f015ab63292290813 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type comparable interface { | |
type int, int8, int16, int32, int64, | |
uint, uint8, uint16, uint32, uint64, | |
float32, float64 | |
} | |
func Max[T comparable](x, y T) T { | |
return T(math.Max(float64(x), float64(y))) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment