From ab533adc68c8eb434bae81f5c70376c5d4ba4733 Mon Sep 17 00:00:00 2001 From: Sebastian Rosengren Date: Fri, 4 Dec 2020 11:36:16 +0100 Subject: [PATCH] Added how to use dispatch on instance methods --- docs/source/resolution.rst | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/docs/source/resolution.rst b/docs/source/resolution.rst index 65f516c..469da60 100644 --- a/docs/source/resolution.rst +++ b/docs/source/resolution.rst @@ -237,3 +237,20 @@ then one of the competing functions will be selected pseudo-randomly. By default the selection is dependent on hash, so it will be consistent during the interpreter session, but it might change from session to session. + +Instance Methods +----------- + +If you need multiple dispatch on instance methods, then you would omit providing a type for ``self`` + +.. code:: + + class X: + + @dispatch(int) + def f(self, y): + ... + + @dispatch(int, int) + def f(self, y, z): + ...