#Can't figure out how to pass classes/types as parameters
8 messages · Page 1 of 1 (latest)
I think what you're looking for is the Variant type, also class is reserved so don't use it as a param name.
class A:
var p = 123
func _ready():
var a = A.new()
test(a)
func test(my_class: Variant):
return my_class is A
That's not what I want, I would like to have A be also a parameter
so that I given a class instance and a class, I can check if the instance is of a certain class (this is the simplified use case, I actually need it for more useful stuff)
Sorry I just realized what you wanted I think
I'm probably asking too much of the burgeoning type system
Yeah I don't think it is supported GD has a strange way of comparing two types. Like for comparing int types for example it looks like this:
print(typeof(value) == TYPE_INT)
Not sure how it would be done with custom classes
You can use is_instance_of(obj, type)