Skip to content

Instantly share code, notes, and snippets.

@jeromewu
Last active June 10, 2021 02:54
Show Gist options
  • Save jeromewu/444bff64c874107f015ab63292290813 to your computer and use it in GitHub Desktop.
Save jeromewu/444bff64c874107f015ab63292290813 to your computer and use it in GitHub Desktop.
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