Instance methods, static methods, class methods
Jump to navigation
Jump to search
✎ This article/section is a stub — some half-sorted notes, not necessarily checked, not necessarily correct. Feel free to ignore, or tell me about it.
(In most languages, the way you will define all of these is considered part of a class)
| can access instance attributes | can access class attributes | intended use | example | notes | |
|---|---|---|---|---|---|
| Instance method | yes | yes (implicitly) | behaviour of each istance | ||
| Class method | no | yes | behaviour that affects class as a whole | create new instances in a way that isn't standard constructor | |
| Static method | no | no | organisation only, really | stuck on the class primarily for organisation's sake. It would often be equally sensible to put it next to the class definition, in the same module. |