Hi folks
I’m not able to get the following to yield the structure for the instance Tst
described in the REPL further below. No error however is reported by Julia.
mutable struct CvDv_ForAll_Voids
CvDv_Trapz :: Array{Float64,2}
CvDv_Trian :: Array{Float64,2}
function CvDv_ForAll_Voids(CvDv_Trapz, CvDv_Trian, NTrapz, NTrian)
Case1 = (NTrapz != 0) & (NTrian != 0)
Case2 = (NTrapz != 0) & (NTrian == 0)
Case3 = (NTrapz == 0) & (NTrian != 0)
Case4 = (NTrapz == 0) & (NTrian == 0)
if Case1==1 new(CvDv_Trapz,CvDv_Trian); end
if Case2==1 new(CvDv_Trapz,zeros(1,2)); end
if Case3==1 new(zeros(1,2),CvDv_Trian); end
if Case4==1 new(zeros(1,2),zeros(1,2)); end
end
end
Inside the REPL, this is what I created and asked in order to form a strucure called Tst
:
julia> A :: Array{Float64,2} = fill(0.75, (4,2))
4×2 Matrix{Float64}:
0.75 0.75
0.75 0.75
0.75 0.75
0.75 0.75
julia> B :: Array{Float64,2} = fill(0.15, (3,2))
3×2 Matrix{Float64}:
0.15 0.15
0.15 0.15
0.15 0.15
julia> Tst = CvDv_ForAll_Voids(A,B,1,1)
julia>
julia> Tst
julia> typeof(Tst)
Nothing
I ran the above using the Debugger on VS Code and did see that Case1
was true
while Case2
, Case3
and Case 4
were all false
. So still why didn’t the inner constructor function return Nothing
rather than create the structure fields using the contents of A
and B
?
Thanks in advance.