'What does TypeError: in Type, in parameter, expected Type got xyz mean in Julia
I'm trying to work on some code and this is the error that I'm getting.
TypeError: in Type, in parameter, expected Type got xyz
Can anyone explain to me what would theoretically cause this to happen? This error message doesn't help me at all. Thanks!
Solution 1:[1]
I was getting very similar error when incorrectly defining the return type of NamedTuples.
The correct way to do this is e.g.:
function fun(arg1::Int64, arg2::Float64)::NamedTuple{(:s1,:s2), Tuple{Int64, Float64}}
return (s1=arg1, s2=arg2)
end
Also, it's useful to check the type of the instance you return to see the structure of the type signature, which you can then just copy-paste. E.g.
julia> typeof(fun(1, 2.))
NamedTuple{(:s1, :s2), Tuple{Int64, Float64}}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | BoZenKhaa |
