Compare commits

...

1 Commits

Author SHA1 Message Date
9f9d8fc661 container: Give Option a "Default" method 2025-10-19 10:16:57 -04:00

View File

@ -29,3 +29,12 @@ func (option Option[T]) Exists () bool {
func (option Option[T]) Value () (T, bool) {
return option.value, option.exists
}
// Default returns the value if it exists, and the specified default value
// otherwise.
func (option Option[T]) Default(defaul T) T {
if value, ok := option.Value(); ok {
return value
}
return defaul
}