and with that, goes:
import Base: length
length{N}(x::SomeType{N}) = N
On Wednesday, March 9, 2016 at 5:18:18 AM UTC-5, jw3126 wrote:
>
> Nice this is much cleaner!
>
> On Wednesday, March 9, 2016 at 10:49:03 AM UTC+1, Milan Bouchet-Valat
> wrote:
>>
>> Le mercredi 09 mars 2016 à 01:41 -0800, jw3126 a écrit :
>> > I want to construct an immutable parametrized by a number dim, which
>> > has a field of type Tuple{Int64, Int64, ... } where Int64 is repeated
>> > dim times. I tried
>> >
>> > immutable SomeType{dim}
>> > x :: Tuple{repeat([Int64], outer = [dim])...}
>> > end
>> >
>> > However this gives the following error:
>> >
>> > LoadError: TypeError: typeassert: expected Array{Int64,N}, got
>> > Array{TypeVar,1}
>> > while loading In[8], in expression starting on line 1
>> >
>> > What is the recommended way to construct such a type?
>> Try this:
>> immutable SomeType{N}
>> x::NTuple{N, Int64}
>> end
>>
>>
>> Regards
>>
>