Recursive type?

is it possible to define a recursive type such that it will store a concrete type at the end?

julia> struct Recur
           data::RecurOrInt64
       end
ERROR: UndefVarError: RecurOrInt64 not defined
Stacktrace:
 [1] top-level scope at none:0

julia> RecurOrInt64 = Union{Recur, Int64}
ERROR: UndefVarError: Recur not defined
Stacktrace:
 [1] top-level scope at none:0
julia> struct Recur
           data::Union{Recur,Int64}
       end

julia> RecurOrInt64 = Union{Recur, Int64}
Union{Recur, Int64}

julia> rr12 = Recur(Recur(12))
Recur(Recur(12))

julia> typeof(rr12.data)
Recur

julia> typeof(rr12.data) <: RecurOrInt64
true
2 Likes