From b2acbeb3a32f3facd5572d9d4abc405d3fa4914f Mon Sep 17 00:00:00 2001 From: Milan Bouchet-Valat Date: Wed, 31 Aug 2016 12:40:21 +0200 Subject: [PATCH] Add docstrings for isequal() and isless() on Nullables --- base/nullable.jl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/base/nullable.jl b/base/nullable.jl index 2a8b9d4497ea9..b7ab7cfdef18f 100644 --- a/base/nullable.jl +++ b/base/nullable.jl @@ -96,6 +96,13 @@ typealias NullSafeTypes Union{NullSafeInts, NullSafeFloats} null_safe_op{S<:NullSafeTypes, T<:NullSafeTypes}(::typeof(isequal), ::Type{S}, ::Type{T}) = true +""" + isequal(x::Nullable, y::Nullable) + +If neither `x` nor `y` is null, compares them according to their values +(i.e. `isless(get(x), get(y))`). Else, returns `true` if both arguments are null, +and `false` if one is null but not the other: nulls are considered equal. +""" function isequal{S,T}(x::Nullable{S}, y::Nullable{T}) if null_safe_op(isequal, S, T) (x.isnull & y.isnull) | (!x.isnull & !y.isnull & isequal(x.value, y.value)) @@ -108,6 +115,14 @@ isequal(x::Nullable{Union{}}, y::Nullable{Union{}}) = true isequal(x::Nullable{Union{}}, y::Nullable) = y.isnull isequal(x::Nullable, y::Nullable{Union{}}) = x.isnull +""" + isless(x::Nullable, y::Nullable) + +If neither `x` nor `y` is null, compares them according to their values +(i.e. `isless(get(x), get(y))`). Else, returns `true` if only `y` is null, and `false` +otherwise: nulls are always considered greater than non-nulls, but not greater than +another null. +""" function isless{S,T}(x::Nullable{S}, y::Nullable{T}) # NULL values are sorted last if null_safe_op(isless, S, T)