Help with understanding Julia types

Hi, I am relatively new to Julia, can you explain what difference between Union {Missing,T}, Vector{Bool}, [Union{Missing, Bool} are, please? Thanks!

Union{Missing, Bool} is a sum type union between Missing and Bool. That is the value can be either of type Missing or of type Bool.

Vector{Union{Missing, Bool}} is a 1-D array where the elements could be either of type Missing or of Bool.

Union{Missing, Bool}[true, false, missing] is a literal syntax to create a Vector{Union{Missing, Bool}}.

julia> A = Union{Missing, Bool}[true, false, missing]
3-element Vector{Union{Missing, Bool}}:

julia> typeof(A)
Vector{Union{Missing, Bool}} (alias for Array{Union{Missing, Bool}, 1})

Thank you so much!!!

1 Like