able to get product
This commit is contained in:
11
pkg/xdefault/withdefault.go
Normal file
11
pkg/xdefault/withdefault.go
Normal file
@ -0,0 +1,11 @@
|
||||
package xdefault
|
||||
|
||||
import "reflect"
|
||||
|
||||
func WithFallback[T comparable](value, fallback T) T {
|
||||
if reflect.ValueOf(value).IsZero() {
|
||||
return fallback
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
Reference in New Issue
Block a user