'How to specify any/unknown/variant type in GDScript?
Is there a way to specify an unknown type in GDScript?
GDScript docs use the type Variant for this (for example in Array.count method).
Say, I'd like to write an identity function. I can do it like so:
func identity(x):
return x
But I'd like to declare that both the parameter type and return value could be anything. Something like:
func identity(x: Variant) -> Variant:
return x
This doesn't work though. Variant is not a known type name. I tried various names, bot nothing seems to work.
Is the only option to leave off the type?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
