Skip to content

Commit

Permalink
Fix #3 by checking for nothingness and type
Browse files Browse the repository at this point in the history
  • Loading branch information
helgee committed Nov 6, 2018
1 parent df19d37 commit 7b154e0
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/OptionalData.jl
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@ push!(opt::OptData{T}, args...) where {T} = push!(opt, T, args...)
Get data from `opt`. Throw an exception if no data has been pushed to `opt` before.
"""
function get(opt::OptData)
function get(opt::OptData{T}) where T
!isavailable(opt) && error(opt.name, " is not available. ", opt.msg)
opt.data
opt.data::T
end

"""
Expand All @@ -71,6 +71,6 @@ end
Check whether data has been pushed to `opt`.
"""
isavailable(opt::OptData) = opt.data != nothing
isavailable(opt::OptData) = opt.data !== nothing

end # module

0 comments on commit 7b154e0

Please sign in to comment.