golang.org/x/playground@v0.0.0-20230418134305-14ebe15bcd59/examples/min.gotip.txt (about) 1 // Title: Generic min 2 package main 3 4 import ( 5 "fmt" 6 "constraints" 7 ) 8 9 func min[P constraints.Ordered](x, y P) P { 10 if x < y { 11 return x 12 } else { 13 return y 14 } 15 } 16 17 func main() { 18 fmt.Println(min(42, 24)) 19 }