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

Need a little help with parametric types

$
0
0

I want to prepare a example but aren’t able to create it. Can someone help me :slight_smile:

julia> struct ModInt{N <: Integer} <: Integer
           k::Integer
           ModInt{N}(k::Integer) where {N <: Integer} = new(mod(k,N))
       end

julia> ModInt{2}(1)
ERROR: TypeError: in ModInt, in N, expected N<:Integer, got a value of type Int64
Stacktrace:
 [1] top-level scope at REPL[2]:1

Thank you!

6 posts - 2 participants

Read full topic


Viewing all articles
Browse latest Browse all 2795

Trending Articles