Optional value handling for Julia
Author tkf
14 Stars
Updated Last
1 Year Ago
Started In
July 2020

Maybe.jl: Optional value handling for Julia

Dev GitHub Actions

Maybe.jl provides functions and macros for handling the values of type Union{Some,Nothing}; i.e., option type. The main entry point for the optional value handling is the macro @?:

julia> using Maybe

julia> data = [1, 3, 2, 1];

julia> @? data[findfirst(iseven, data)]

julia> y = @? data[findfirst(>=(4), data)]

julia> @assert y === nothing

Maybe.jl also provides low-level functions such as Maybe.get which is the "Maybe" variant of Base.get:

julia> Maybe.get(Dict(:a => 1), :a)

julia> @assert Maybe.get(Dict(:a => 1), :b) === nothing

See more in the documentation.

Required Packages

Used By Packages

No packages found.