mirror of
https://github.com/godotengine/godot.git
synced 2025-11-01 14:11:15 +00:00
GDScript: Use "is" keyword for type checking.
Replaces the `extends` keyword with `is` in the context of testing for type compatibility.
`extends` is still used for declaring class inheritance.
Example:
```gdscript
extends Node2D
func _input(ev):
if ev is InputEventKey:
print("yay, key event")
```
This commit is contained in:
parent
f89641907f
commit
015d36d18b
7 changed files with 12 additions and 8 deletions
|
|
@ -358,12 +358,12 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
|
|||
|
||||
if (a->get_type() != Variant::OBJECT || a->operator Object *() == NULL) {
|
||||
|
||||
err_text = "Left operand of 'extends' is not an instance of anything.";
|
||||
err_text = "Left operand of 'is' is not an instance of anything.";
|
||||
break;
|
||||
}
|
||||
if (b->get_type() != Variant::OBJECT || b->operator Object *() == NULL) {
|
||||
|
||||
err_text = "Right operand of 'extends' is not a class.";
|
||||
err_text = "Right operand of 'is' is not a class.";
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -401,7 +401,7 @@ Variant GDFunction::call(GDInstance *p_instance, const Variant **p_args, int p_a
|
|||
|
||||
if (!nc) {
|
||||
|
||||
err_text = "Right operand of 'extends' is not a class (type: '" + obj_B->get_class() + "').";
|
||||
err_text = "Right operand of 'is' is not a class (type: '" + obj_B->get_class() + "').";
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue