Problem with type mismatch -- MethodError: no method matching

When you declare a function with keyword arguments like this:

function foo(x; y = 10)
end

then you must provide the keywords when you call the function:

foo(1, y = 2)  # NOT: foo(1, 2)

By the way, it will be easier to read your code (and help you) if you format it correctly with backticks:

2 Likes