-
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
Closed
Labels
missing dataBase.missing and related functionalityBase.missing and related functionality
Description
Title says it all. It's possible to create two objects which are printed as Nullable{Int}() and are not supposed to differ in any way, and yet are actually different according to ===. This is because:
julia> dump(Nullable(0, true))
Nullable{Int64}
isnull: Bool true
value: Int64 0
julia> dump(Nullable{Int}())
Nullable{Int64}
isnull: Bool true
value: Int64 1This is particularly annoying when writing tests, but it can also be disturbing in real uses.
For non-isbits types, a solution is to discard the value in the constructor when true, i.e.:
Nullable{T}(value::T, isnull::Bool=false) = ifelse(isnull, Nullable{T}(), Nullable(value))But this doesn't work for isbits types, for which the field contains random values when left uninitialized. I guess there's a way to fill the value field with zeros à la reinterpret, but what's the best way to do it?
Cc: @johnmyleswhite
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
missing dataBase.missing and related functionalityBase.missing and related functionality