I really doubt that it can be expressed this way, because Julia will do pattern matching/unification on the type of `bar`, and it would have to know that -1 is the inverse of +1 to unify D+1 with the type of the input array. Can you give more context about what you're trying to do? Why can't you have `bar::Array{Any, D}`?
You can also put D inside the constructor type Foo{E} bar::Array{Any, E} end Foo(D::Int) = Foo(Array{Any, D+1}()) Foo(1) or use typealias On Wednesday, June 1, 2016 at 2:56:28 PM UTC-4, Robert DJ wrote: > > I have a custom type with a TypePar denoting a dimension and would like to > define the following: > > type Foo{D} > bar::Array{D+1} > end > > However, this does not work. As D is only 1 or 2 it would OK with > > type Foo{1} > bar::Matrix > end > > type Foo{2} > bar::Array{3} > end > > but unfortunately this isn't working, either. > > Can this problem be solved? > > Thanks! >