+1 vote

I can do a setter and getter and just use has_method("getter"), but is there a more convenient way to just verify if the object has a variable?

in Engine by (1,093 points)

2 Answers

+4 votes
Best answer

You can check this with in keyword. Like for example:

if "varName" in get_parent(): print("varName is defined in parent!")
by (1,281 points)
selected by
+1 vote

Check my question here some time ago about the same subject: link

by (427 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.