Er...
Er...

Reputation: 643

Right way to type as "Any"

Let's say I'm using gdscript static typing and for one function parameter I don't know in advance what I'm going to get. That's what typing.Any is for in python. How do I do it with gdscript?

It seems that Variant is not a valid type and I'm not sure about using Object for that purpose (since it could be a built-in)

edit Leaving the type blank obviously works, but the docs have a specific section called typed-or-dynamic-stick-to-one-style, and since we're already kinda short on good practices using gdscript I'd rather find another way

Any idea?

Upvotes: 3

Views: 2477

Answers (1)

Calinou
Calinou

Reputation: 949

As of Godot 3.2, GDScript does not feature a Variant or any type hint yet. However, you can still use the Object type hint if you expect a variable to hold any object (or null, as Object is nullable by design). Object may not hold primitive types like int or bool though.

Therefore, you should just leave out the type hint for now.

Upvotes: 6

Related Questions