File tree 3 files changed +19
-2
lines changed
3 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -105,5 +105,5 @@ immutable Nullable{T}
105
105
value:: T
106
106
107
107
Nullable () = new (true )
108
- Nullable (value:: T ) = new (false , value)
108
+ Nullable (value:: T , isnull :: Bool = false ) = new (isnull , value)
109
109
end
Original file line number Diff line number Diff line change 3
3
immutable NullException <: Exception
4
4
end
5
5
6
- Nullable {T} (value:: T ) = Nullable {T} (value)
6
+ Nullable {T} (value:: T , isnull :: Bool = false ) = Nullable {T} (value, isnull )
7
7
Nullable () = Nullable {Union()} ()
8
8
9
9
eltype {T} (:: Type{Nullable{T}} ) = T
Original file line number Diff line number Diff line change @@ -40,6 +40,23 @@ for T in types
40
40
@test eltype (x) === T
41
41
end
42
42
43
+ # Nullable{T}(value::T, isnull::Bool) = new(isnull, value)
44
+ for T in types
45
+ x = Nullable {T} (zero (T),false )
46
+ @test x. isnull === false
47
+ @test isa (x. value, T)
48
+ @test x. value === zero (T)
49
+ @test eltype (x) === T
50
+
51
+ x = Nullable {T} (zero (T),true )
52
+ @test x. isnull === true
53
+ @test isa (x. value, T)
54
+ @test eltype (Nullable{T}) === T
55
+ @test eltype (x) === T
56
+ end
57
+
58
+
59
+
43
60
# immutable NullException <: Exception
44
61
@test isa (NullException (), NullException)
45
62
@test_throws NullException throw (NullException ())
You can’t perform that action at this time.
0 commit comments