TheSmolCodar
TheSmolCodar

Reputation: 57

Is there a way for variables to have a few types in GDScript

I know GDScript has dynamic typing, but I was wondering if there was a way to give a variable only a few types it can have. Something like this:

var myVar : int : string = 12;
myVar = "Hello";

Does it have a feature like this?

Upvotes: 1

Views: 2422

Answers (1)

Theraot
Theraot

Reputation: 40305

No. This is not supported in GDScript.

There is a relevant proposal: https://github.com/godotengine/godot-proposals/issues/737 (The syntax would be var myVar: int|string). However, it is not part of the Godot 4.0 milestone.

Upvotes: 4

Related Questions