Closed jsofra closed 10 years ago
Nice find, I was testing the dispatch value for logical true, when I should have done "is not None". 0 is "falsey". Will fix and publish today. thanks!
The fix stops caring about what the boolean interpretation of the dispatch value is.
As it looks for matches, it now starts off with Default
, and if that ends up being the best match, it's returned (or throw exception if there's no default dispatch function). So now dispatch values of 0, False, and None should work fine.
Fix is in 0.4.1
I am unable to define a method that dispatches on the value 0.
from multimethods import MultiMethod
def dispatch(x): return x
foo = MultiMethod('foo', dispatch)
foo.addmethod(lambda x: "yep", 0)
multimethods.DispatchException: No matching method on multimethod 'foo' for '0', and no default method defined