the `names` function is indeed the right way to go about it:

julia> un = Union(Int, Float64)
Union(Int64,Float64)

julia> names(un)
1-element Array{Symbol,1}:
 :types

julia> un.types
(Int64,Float64)

julia> un.types[1]
Int64

julia> un.types[2]
Float64


For datatypes:

julia> type A
       a::Int
       b::Float64
       end

julia> names(DataType)
14-element Array{Symbol,1}:
 :fptr        
 :env         
 :code        
 :name        
 :super       
 :parameters  
 :names       
 :types       
 :ctor_factory
 :instance    
 :size        
 :abstract    
 :mutable     
 :pointerfree 

julia> A.types
(Int64,Float64)

Also have a look at this excellent post:
http://blog.leahhanson.us/julia-helps.html


On Fri, 2014-05-16 at 08:09, tony.hf.f...@gmail.com wrote:
> Hello, new user and subscriber here. Is there a way to decompose a 
> UnionType back into its constituent type(s)?
>
> I tried names():
>
>> dt = Union(Int,Float64)
>> names(dt)
> 1-element Array{Symbol,1}:
>  :types
>
> convert() seems to hit dead-ends.
>
> Help appreciated.
>
> Tony

-- 

Reply via email to