Compare commits
1 Commits
Author | SHA1 | Date | |
---|---|---|---|
9f9d8fc661 |
@ -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
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user