Recursive type of named tuple


#1

I want to create an array of named tuples of type T, where one field of the tuple, named ‘bak’, is recursive. Or, in other words, it can be either ‘nothing’ or of type T. How do I do this?

tmp=[(bak=nothing)]
push!(tmp,(bak=(bak=nothing,),))

ERROR: MethodError: Cannot `convert` an object of type NamedTuple{(:bak,),Tuple{Nothing}} to an object of type Nothing

#2
tmp=Array{NamedTuple{(:bak,),T} where T<:Tuple,1}()
push!(tmp,(bak=nothing,))
push!(tmp,(bak=(bak=nothing,),))

#3

Thank you!