-
Notifications
You must be signed in to change notification settings - Fork 18
Open
Description
This would be a parallel to the fromMaybe
function in Data.Maybe
in Haskell. The definition would be sorta like this:
frommissing(default::T, value::Union{Missing, T}) where {T} = ismissing(value) ? default : value
The usage / tests could be as follows:
@test frommissing(4, missing) == 4
@test frommissing(4, 10) == 10
@test_throws MethodError frommissing(4, 10.0) # type mismatch
@test frommissing.(4, [missing, 10]) == [4, 10]
Thoughts? Would a PR be accepted?
Metadata
Metadata
Assignees
Labels
No labels