Difference between revisions of "Is"

From Lazarus wiki
Jump to navigationJump to search
(remove “back to <some arbitrary page>” link, as there are multiple pages linking here)
 
(2 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
{{Is}}
 
{{Is}}
  
The [[Reserved word|reserved word]] <syntaxhighlight lang="pascal" enclose="none">is</syntaxhighlight> belongs to [[object-oriented programming]].
+
The [[Reserved word|reserved word]] <syntaxhighlight lang="delphi" inline>is</syntaxhighlight> appears as:
The <syntaxhighlight lang="pascal" enclose="none">is</syntaxhighlight> operator is used to test whether the object is an instance of the specified [[Type|type]] ([[Class|class]] or child class). It takes an object on the left side of the <syntaxhighlight lang="pascal" enclose="none">is</syntaxhighlight> operator and
 
a type on the right side of the operator. The result is the value of [[Boolean|boolean]] indicating whether the object belongs to this type or not.
 
  
Example:
+
* an [[Operator|operator symbol]] in [[object-oriented programming]], or as a
 +
* a modifier qualifying [[Procedural variable|routine variable]] (<syntaxhighlight lang="delphi" inline>is nested</syntaxhighlight>).
  
<syntaxhighlight>
+
== Operator ==
  ...
+
 
  If fruit is TCitrusFruit then ... // Check if the fruit object belongs to the class of TCitrusFruit
+
The operator <syntaxhighlight lang="delphi" inline>is</syntaxhighlight> tests, whether an object (first operand) is an instance of a [[Class|class]] or its children.
  ...
+
<syntaxhighlight lang="delphi">fruit is citrusFruit</syntaxhighlight>is equivalent to<syntaxhighlight lang="delphi">fruit.inheritsFrom(citrusFruit)</syntaxhighlight>.
</syntaxhighlight>
+
The [[expression]] is [[false and true|<syntaxhighlight lang="pascal" inline>true</syntaxhighlight>]] if and only if <syntaxhighlight lang="pascal" inline>fruit</syntaxhighlight> descends from <syntaxhighlight lang="pascal" inline>citrusFruit</syntaxhighlight>.
 +
 
 +
== Modifier ==
 +
 
 +
If <syntaxhighlight lang="pascal" inline>{$modeSwitch nestedProcVars+}</syntaxhighlight> or [[Mode iso|<syntaxhighlight lang="pascal" inline>{$mode ISO}</syntaxhighlight>]] routine variables declared with the modifier <syntaxhighlight lang="delphi" inline>is nested</syntaxhighlight> allows those to be assigned to nested routines.
 +
Otherwise only global routines' addresses can be assigned to routine variables.

Latest revision as of 09:07, 16 May 2020

Deutsch (de) English (en) suomi (fi)

The reserved word is appears as:

Operator

The operator is tests, whether an object (first operand) is an instance of a class or its children.

fruit is citrusFruit

is equivalent to

fruit.inheritsFrom(citrusFruit)

.

The expression is true if and only if fruit descends from citrusFruit.

Modifier

If {$modeSwitch nestedProcVars+} or {$mode ISO} routine variables declared with the modifier is nested allows those to be assigned to nested routines. Otherwise only global routines' addresses can be assigned to routine variables.