Skip to content

Commit

Permalink
Change isnull argument to Nullable() constructor to hasvalue
Browse files Browse the repository at this point in the history
This method is not currently documented, and the new form is more consistent
with the new structure of the type.
  • Loading branch information
nalimilan committed Sep 15, 2016
1 parent 8da3c10 commit fcd065d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion base/base.jl
Original file line number Diff line number Diff line change
Expand Up @@ -150,5 +150,5 @@ immutable Nullable{T}
value::T

Nullable() = new(false)
Nullable(value::T, isnull::Bool=false) = new(!isnull, value)
Nullable(value::T, hasvalue::Bool=true) = new(hasvalue, value)
end
2 changes: 1 addition & 1 deletion base/nullable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
immutable NullException <: Exception
end

Nullable{T}(value::T, isnull::Bool=false) = Nullable{T}(value, isnull)
Nullable{T}(value::T, hasvalue::Bool=true) = Nullable{T}(value, hasvalue)
Nullable() = Nullable{Union{}}()

eltype{T}(::Type{Nullable{T}}) = T
Expand Down
6 changes: 3 additions & 3 deletions test/nullable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ for T in types
@test eltype(x) === T
end

# Nullable{T}(value::T, isnull::Bool) = new(isnull, value)
# Nullable{T}(value::T, hasvalue::Bool) = new(hasvalue, value)
for T in types
x = Nullable{T}(zero(T),false)
x = Nullable{T}(zero(T), true)
@test x.hasvalue === true
@test isa(x.value, T)
@test x.value === zero(T)
@test eltype(x) === T

x = Nullable{T}(zero(T),true)
x = Nullable{T}(zero(T), false)
@test x.hasvalue === false
@test isa(x.value, T)
@test eltype(Nullable{T}) === T
Expand Down

0 comments on commit fcd065d

Please sign in to comment.