Programming FundamentalsBeginner
Method
تابعة
PronunciationMETH-ud
Definition
A function that is associated with an object or class, defining the behaviors or actions that the object can perform.
Where you hear it
In object-oriented programming, when defining what an object can do, or when calling a function on an instance.
Examples
The
userobject has asavemethod to persist its data to the database.We added a helper method to calculate the total price of the cart items.
Common mistake
Calling any function a method, even when it is written outside of any class or object context.
Keep exploring
More in Programming Fundamentals