Difference between revisions of "Method"
From Free Pascal wiki
Jump to navigationJump to search (static class methods (see diff 117812)) |
|||
Line 7: | Line 7: | ||
In static or class methods it identifies the <syntaxhighlight lang="pascal" enclose="none">object</syntaxhighlight>/<syntaxhighlight lang="pascal" enclose="none">class</syntaxhighlight> type itself. | In static or class methods it identifies the <syntaxhighlight lang="pascal" enclose="none">object</syntaxhighlight>/<syntaxhighlight lang="pascal" enclose="none">class</syntaxhighlight> type itself. | ||
In instance methods <syntaxhighlight lang="pascal" enclose="none">self</syntaxhighlight> identifies the very instance. | In instance methods <syntaxhighlight lang="pascal" enclose="none">self</syntaxhighlight> identifies the very instance. | ||
+ | |||
+ | However, since static class methods are just “global” routines within the type's namespace, such methods do not know the <syntaxhighlight lang="pascal" enclose="none">self</syntaxhighlight> identifier. | ||
+ | [https://www.freepascal.org/docs-html/ref/refsu30.html ¹][https://www.freepascal.org/docs-html/ref/refsu22.html#x66-880005.5.2 ²] |
Revision as of 19:26, 26 May 2018
│
English (en) │
français (fr) │
русский (ru) │
A method is a routine that is associated with an object
or class
.
self identifier
Inside method definitions the special identifier self
is available.
In static or class methods it identifies the object
/class
type itself.
In instance methods self
identifies the very instance.
However, since static class methods are just “global” routines within the type's namespace, such methods do not know the self
identifier.
¹²