Hi,
I was trying to define a function that would work on all integer types, and could not get it to work when the input is matrix or vector.
functions taking in single value of Int64 or Integer work fine. But if I call a function expecting Vector{Integer} with input of Vector{Int64} it does not work.
Is there a way to work around this? Or am I doing something wrong here?
f1(x::Integer) = display(x)
f2(x::Int64) = display(x)
f1(x::Vector{Integer}) = display(x)
f2(x::Vector{Int64}) = display(x)
v = collect(1:5);
# These work
f1(v[1])
f2(v[1])
# This also works
f2(v)
# But this doesn't
f1(v)
The error I get:
julia> f1(v)
ERROR: MethodError: no method matching f1(::Vector{Int64})
Closest candidates are:
f1(::Integer) at REPL[34]:1
f1(::Vector{Integer}) at REPL[36]:1
Stacktrace:
[1] top-level scope
@ REPL[45]:1