Skip to content

Commit

Permalink
improve help for isnull and simplify Nullable definitions a bit
Browse files Browse the repository at this point in the history
  • Loading branch information
JeffBezanson committed Dec 14, 2014
1 parent cdb6f7c commit 1666552
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions base/nullable.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ eltype{T}(::Type{Nullable{T}}) = T

eltype{T}(x::Nullable{T}) = T

function convert{S, T}(::Type{Nullable{T}}, x::Nullable{S})
function convert{T}(::Type{Nullable{T}}, x::Nullable)
return isnull(x) ? Nullable{T}() : Nullable(convert(T, get(x)))
end

Expand All @@ -29,11 +29,11 @@ end

get(x::Nullable) = x.isnull ? throw(NullException()) : x.value

get{S, T}(x::Nullable{S}, y::T) = x.isnull ? convert(S, y) : x.value
get{T}(x::Nullable{T}, y) = x.isnull ? convert(T, y) : x.value

isnull(x::Nullable) = x.isnull

function isequal{S, T}(x::Nullable{S}, y::Nullable{T})
function isequal(x::Nullable, y::Nullable)
if x.isnull && y.isnull
return true
elseif x.isnull || y.isnull
Expand All @@ -43,7 +43,7 @@ function isequal{S, T}(x::Nullable{S}, y::Nullable{T})
end
end

=={S, T}(x::Nullable{S}, y::Nullable{T}) = throw(NullException())
==(x::Nullable, y::Nullable) = throw(NullException())

const nullablehash_seed = UInt === UInt64 ? 0x932e0143e51d0171 : 0xe51d0171

Expand Down
2 changes: 1 addition & 1 deletion doc/stdlib/base.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ Nullables

.. function:: isnull(x)

Does the ``Nullable`` object ``x`` have a value or not?
Is the ``Nullable`` object ``x`` null, i.e. missing a value?

Strings
-------
Expand Down

0 comments on commit 1666552

Please sign in to comment.