Skip to content

Commit

Permalink
Add 'isassigned' for RefValue
Browse files Browse the repository at this point in the history
  • Loading branch information
malmaud committed Jan 24, 2017
1 parent 3b97b4f commit f4d970f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions base/refpointer.jl
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type RefValue{T} <: Ref{T}
RefValue(x) = new(x)
end
RefValue{T}(x::T) = RefValue{T}(x)
isassigned(x::RefValue) = isdefined(x, :x)

Ref(x::Ref) = x
Ref(x::Any) = RefValue(x)
Expand Down
8 changes: 8 additions & 0 deletions test/misc.jl
Original file line number Diff line number Diff line change
Expand Up @@ -611,3 +611,11 @@ end
@test Foo_19281().f[1] == ()
@test Foo_19281().f[2] == (1, )
end

let
x_notdefined = Ref{String}()
@test !isassigned(x_notdefined)

x_defined = Ref{String}("Test")
@test isassigned(x_defined)
end

0 comments on commit f4d970f

Please sign in to comment.