1
0
mirror of https://github.com/golang/go synced 2024-11-11 19:41:36 -07:00
This commit is contained in:
Carl Johnson 2023-09-22 10:56:40 -04:00
parent 336dd86b34
commit a8a223871f

View File

@ -60,7 +60,8 @@ func isNaN[T Ordered](x T) bool {
// Or returns the first of its arguments that is not equal to the zero value.
// If no argument is non-zero, it returns the zero value.
func Or[T any](vals ...T) T {
func Or[T comparable](vals ...T) T {
var zero T
for _, val := range vals {
if val != zero {
return val