Parametric Type Ctor


#1

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.


#2

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

a4=TBSCM{Float64,4}(s)

#3

Oops, thank you very much !


#4

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


#5

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