diff options
author | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-22 16:51:34 +0100 |
---|---|---|
committer | Rémi Verschelde <rverschelde@gmail.com> | 2023-02-22 16:51:34 +0100 |
commit | 999bb91dc670882742bb28c698297f110ca3fd0b (patch) | |
tree | 833b7db7fdc692e0582bbf0d96092c7ead186ce8 /modules/gdscript | |
parent | 868be8004bf126365e1b002ca777c6bb2641e0cf (diff) | |
parent | a98a0f5d34074735678b73f7dfac22ea42b8e3e0 (diff) |
Merge pull request #73761 from dalexeev/doc-gds-is-instance-of
Document `@GDScript.is_instance_of` method
Diffstat (limited to 'modules/gdscript')
-rw-r--r-- | modules/gdscript/doc_classes/@GDScript.xml | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/modules/gdscript/doc_classes/@GDScript.xml b/modules/gdscript/doc_classes/@GDScript.xml index 08c8763493..045505b720 100644 --- a/modules/gdscript/doc_classes/@GDScript.xml +++ b/modules/gdscript/doc_classes/@GDScript.xml @@ -126,6 +126,20 @@ <param index="0" name="value" type="Variant" /> <param index="1" name="type" type="Variant" /> <description> + Returns [code]true[/code] if [param value] is an instance of [param type]. The [param type] value must be one of the following: + - A constant from the [enum Variant.Type] enumeration, for example [constant TYPE_INT]. + - An [Object]-derived class which exists in [ClassDB], for example [Node]. + - A [Script] (you can use any class, including inner one). + Unlike the right operand of the [code]is[/code] operator, [param type] can be a non-constant value. The [code]is[/code] operator supports more features (such as typed arrays) and is more performant. Use the operator instead of this method if you do not need dynamic type checking. + Examples: + [codeblock] + print(is_instance_of(a, TYPE_INT)) + print(is_instance_of(a, Node)) + print(is_instance_of(a, MyClass)) + print(is_instance_of(a, MyClass.InnerClass)) + [/codeblock] + [b]Note:[/b] If [param value] and/or [param type] are freed objects (see [method @GlobalScope.is_instance_valid]), or [param type] is not one of the above options, this method will raise an runtime error. + See also [method @GlobalScope.typeof], [method type_exists], [method Array.is_same_typed] (and other [Array] methods). </description> </method> <method name="len"> |