Parametric Type Ctor

Hello,
I want to build a type named TBSCM with tho parameter and I have problem with the constructor…


struct TBSCM{T,N}
    data::Array{T,2}
    function TBSCM{T,N}(s::Int) where T where N
        new{T,N}(zeros(T,N,s))
    end 
end

s=10^6

a4=TBSCM{4}(s)

returns an error like it ignore the Ctor…
Thank you for your help.

Don’t you need a constructor something like the following to fill in both T and N?

a4=TBSCM{Float64,4}(s)
1 Like

Oops, thank you very much !

Semi irrelevant but the constructor would be better off as an outer constructor.

1 Like

At least not irrelevant for me. I am learning Julia and I have to understand the programming style as well.