instance method
In this example, sum()
is an instance method of the MyClass
class. It takes the instance itself (self
) as the first argument, and returns the sum of x
and y
. To call this method, we first need to create an instance of the class, and then use the dot notation to call the method on that instance:
Last updated