-
-
Notifications
You must be signed in to change notification settings - Fork 21.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add enums to GDScript #2966
Comments
The wanted behaviour can be somewhat achieved with:
It's less elegant of course (and the variables would be CORNER.W and not CORNER_W) :) Regarding the custom values ideas, it just boils down to supporting multiple assignments:
|
+1 Would really love to use enums. But I don't think "var" enums are really helpful. (I think you mean "var" by being able to reassign enum values like |
@WeAthFoLD ~ No, I don't have any use case in mind about them. Just added them as an option… 😄 |
IMO enumerations are constants by nature, which is true in many other languages. If you allow enums to be variable and regard them as sth like syntax sugar of multiple assignments, they will be somewhat misleading >_ |
What about naming the enum, so we can write |
@Zylann I don't see the point since GDScript is dinamically typed. But if the above is implemented, you could do something like this: class Corner:
enum { W, NW, NE, E, SE, SW } |
You could use named enums to put them into |
So, is |
@Sslaxx Well, yeah, depending on what you want from it. All three of those are valid:
|
The point I see in "namespacing" is actually being able to name the enum, so it could be used in export for example (instead of writing all possible values twice), or documented. |
@Zylann Yeah, that's planned, though it would be nice if you open an issue about it 😄 |
Fixes godotengine#2966 (cherry picked from commit 4ee82a2)
TL;DR
I would like to avoid writing
And be able to write it like:
Some more ideas
Those ideas might simplify the usual workflow, or add additional features for strange workflows or setups.
Nice addition to avoid repetition:
Custom values idea 1:
Custom values idea 2:
Maybe
enum
should be prefixed byconst
orvar
depending on use? (IMO, it would be better to assumeconst
, as to not create ambiguities, and/or hard to understand code)The text was updated successfully, but these errors were encountered: