Source Code:
(back to article)
class MyClass: def f(self, x): if x == 1: return self.g() elif x == 2: return self.h() elif x == 3: return self.i() else: return "Something else" def g(self): return "Method g" def h(self): return "Method h" def i(self): return "Method i" obj = MyClass() print(obj.f(2))
Result:
Report an issue