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:
Andreas Haas 2017-05-26 19:45:39 +02:00
parent f89641907f
commit 015d36d18b
No known key found for this signature in database
GPG key ID: B5FFAE1B65FBD2E1
7 changed files with 12 additions and 8 deletions

View file

@ -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;
}