You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// OrElse returns the first value if it is a non-zero value,
// “or else” it returns the second.
func OrElse[T comparable](specimen T, ifZero T) {
if specimen == *new(T) {
return ifZero
}
return specimen
}
^^ Useful to replace zero values with some non-zero default.
The text was updated successfully, but these errors were encountered:
^^ Useful to replace zero values with some non-zero default.
The text was updated successfully, but these errors were encountered: