From fcd065dc3d772ea7aeb8ccc525466d7d1015339a Mon Sep 17 00:00:00 2001 From: Milan Bouchet-Valat Date: Thu, 15 Sep 2016 08:21:23 +0200 Subject: [PATCH] Change isnull argument to Nullable() constructor to hasvalue This method is not currently documented, and the new form is more consistent with the new structure of the type. --- base/base.jl | 2 +- base/nullable.jl | 2 +- test/nullable.jl | 6 +++--- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/base/base.jl b/base/base.jl index 09992e6b0834ff..9d9c41cac0fadd 100644 --- a/base/base.jl +++ b/base/base.jl @@ -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 diff --git a/base/nullable.jl b/base/nullable.jl index 649dabff41641e..c8e657ee900109 100644 --- a/base/nullable.jl +++ b/base/nullable.jl @@ -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 diff --git a/test/nullable.jl b/test/nullable.jl index d986be382680d3..6ecbc22a0598d1 100644 --- a/test/nullable.jl +++ b/test/nullable.jl @@ -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