Difference between revisions of "Method"
From Free Pascal wiki
Jump to navigationJump to searchLine 1: | Line 1: | ||
{{Method}} | {{Method}} | ||
− | A '''method''' is a [[Routine|routine]] that is associated with an [[Object|<syntaxhighlight lang="pascal" | + | A '''method''' is a [[Routine|routine]] that is associated with an [[Object|<syntaxhighlight lang="pascal" inline>object</syntaxhighlight>]] or [[Class|<syntaxhighlight lang="pascal" inline>class</syntaxhighlight>]]. |
== self identifier == | == self identifier == | ||
− | Inside method definitions the special identifier <syntaxhighlight lang="pascal" | + | Inside method definitions the special identifier <syntaxhighlight lang="pascal" inline>self</syntaxhighlight> is available. |
− | In static or class methods it identifies the <syntaxhighlight lang="pascal" | + | In static or class methods it identifies the <syntaxhighlight lang="pascal" inline>object</syntaxhighlight>/<syntaxhighlight lang="pascal" inline>class</syntaxhighlight> type itself. |
− | In instance methods <syntaxhighlight lang="pascal" | + | In instance methods <syntaxhighlight lang="pascal" inline>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" | + | However, since static class methods are just “global” routines within the type's namespace, such methods do not know the <syntaxhighlight lang="pascal" inline>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 ²] | [https://www.freepascal.org/docs-html/ref/refsu30.html ¹][https://www.freepascal.org/docs-html/ref/refsu22.html#x66-880005.5.2 ²] | ||
== see also == | == see also == | ||
− | * [[Property|<syntaxhighlight lang="pascal" | + | * [[Property|<syntaxhighlight lang="pascal" inline>property</syntaxhighlight>]] |
Latest revision as of 17:22, 6 August 2022
│
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.
¹²