I'm confused about methods

They should never coexist at the same time, because they have exactly the same signature. (Keyword arguments aren’t actually part of a method’s signature.)

In scenario 1, everything is working as it should; f()=1 gets overridden by f(;a)=2, so that’s exactly the behavior you observe.

In scenario 2, f(;a)=2 should therefore also be completely overridden by f()=1, so methods(f) should only print f(), not f(; a) and f(a=1) should therefore be an UndefVarError.

1 Like