Add has_property() and has_static_property() methods #10031
Closed
azur-wolve
started this conversation in
Scripting
Replies: 1 comment
-
Thank you for your proposal, consolidating in: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Object has
has_method()
to easily check if the method name passed is there.It works for both instance methods and static methods.
(Still feel that should have a
has_static_method()
)But for properties must do a lot of boilerplate to check if has a specific property by its name. →
get_property_list()
and then do lookup on dictionaries.For certain scenarios its fine, but when only want to check fast a single one isn't ideal.
Have coded my own utility methods for that:
Solution → add official methods that do that:
Object.has_property(name: String)
Object.has_static_property(name: String)
and an extra also:
@GlobalScope.normalize_spaces_and_tabs(text: String, strip_edges: bool = false)
In my code example is used to ensure that the source code of the script has only single spaces before checking if has
"static var " + name
.Beta Was this translation helpful? Give feedback.
All reactions