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
When we've been using this library there are often times where it can be useful to apply a function to the interior value of a nullable field before further processing.
While it's a simple utility to write, it feels like it would be an ergonomic to have such a utility exposed as part of this package. Something like
funcMap[T1, T2any](maybeValueNullable[T1], fnfunc(valueT1) T2) Nullable[T2] {
if!maybeValue.IsSpecified() {
returnnil
} elseifmaybeValue.IsNull() {
returnNewNullNullable[T2]()
} else {
// SAFETY: Must is safe to use here as all other states of the nullable.Nullable value// are checked in the above if blocks.returnNewNullableWithValue(fn(maybeValue.MustGet()))
}
}
With a usage like
result:=nullable.Map(maybeValue, func(xint) int { returnx+1 })
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
When we've been using this library there are often times where it can be useful to apply a function to the interior value of a nullable field before further processing.
While it's a simple utility to write, it feels like it would be an ergonomic to have such a utility exposed as part of this package. Something like
With a usage like
The text was updated successfully, but these errors were encountered: