You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following function has a default argument of incompatible type. When calling foo() it looks for foo(::String) which fails with an amusing closest candidate suggestion -- perhaps I meant to call foo()? 😃 This is not too bad though..
julia> function foo(x::Integer="hello")
return 13
end
foo (generic function with 2 methods)
julia> foo()
ERROR: MethodError: no method matching foo(::String)
Closest candidates are:
foo() at REPL[1]:2
foo(::Integer) at REPL[1]:2
Stacktrace:
[1] foo() at ./REPL[1]:2
[2] top-level scope at none:0
What worries me is that the default argument of this method can leak to other methods of foo, as when I continue the example from above with this:
julia> function foo(x::String)
return x * " world"
end
foo (generic function with 3 methods)
julia> foo()
"hello world"
This must be a dispatching bug of some sort?
The text was updated successfully, but these errors were encountered:
The following function has a default argument of incompatible type. When calling
foo()
it looks forfoo(::String)
which fails with an amusing closest candidate suggestion -- perhaps I meant to callfoo()
? 😃 This is not too bad though..What worries me is that the default argument of this method can leak to other methods of
foo
, as when I continue the example from above with this:This must be a dispatching bug of some sort?
The text was updated successfully, but these errors were encountered: