For example:
mutable struct A
a::Int
b::Ref{B}
end
mutable struct B
b::Int
a::Ref{A}
end
For example:
mutable struct A
a::Int
b::Ref{B}
end
mutable struct B
b::Int
a::Ref{A}
end
Finally, I got a solution by Incomplete Initialization
@Julia Manual.
Solution:
mutable struct A{T}
a::Int
b::Ref{T}
A{T}(a::Int) where T = new{T}(a)
end
mutable struct B
b::Int
a::Ref{A{T}} where T
B(b::Int)=new(b)
end
a =A{B}(1)
b = B(2)
a.b=Ref{B}()
a.b[]=b
a.b[].b == 2
b.a=Ref{A{B}}()
b.a[] = a
b.a[].a == 1