For Julia 0.6, NEWS.md indicates that " Union types have two fields, a and b instead of one types field." In addition, "Parametric types with" unspecified "parameters, such as Array , are now represented as UnionAll , not DataType s."
Thus, to get types as a tuple, we can do
union_types(x::Union) = (xa, union_types(xb)...) union_types(x::Type) = (x,)
If you need an array, just collect tuple
julia> collect(union_types(Union{Int, Float64, String, Array})) 4-element Array{Type,1}: Int64 Float64 String Array
source share