Godot Version
4.3.stable.official
Question
I have some simple Parent - Child class hierarchy. I store object of both classes in the dictionary. I often iterate over this dictionary. How can I efficiently cast objects that I get from here? Right now I’m doing something like this:
for p in dict:
var obj= dict[p] as ParentClass
#do something specific to parent class
if obj.get_type() == ChildClass.get_type():
var child_obj = obj as ChildClass
#do something specific for child class
get_type() is static and returns some predefined value, depending on class
I would like to also use strict typing, which will make things even harder.