Quantcast
Channel: First steps - JuliaLang
Viewing all articles
Browse latest Browse all 2795

Type parameters which depend on other type parameters

$
0
0

@jlchan wrote:

Is there a way to specify a type parameter in a way that depends on another type parameter?

For example, a StaticMatrix takes in types {M,N,T,L}, where M,N are dimensions and L is the length of the array. Is there a way to set L=M*N? For example, if I try to define

struct foo{N <: Integer}
    A::SMatrix{N,N,Float64,N*N}
end

I get the error

ERROR: MethodError: no method matching *(::TypeVar, ::TypeVar)

Posts: 6

Participants: 4

Read full topic


Viewing all articles
Browse latest Browse all 2795

Latest Images

Trending Articles



Latest Images