Skip to content

Commit 795df85

Browse files
Added enum iteration example
1 parent 3119d34 commit 795df85

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

tutorials/scripting/gdscript/gdscript_basics.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,13 +1231,18 @@ a dictionary can also be used with a named enum.
12311231

12321232
# Is the same as:
12331233
const State = {STATE_IDLE = 0, STATE_JUMP = 5, STATE_SHOOT = 6}
1234+
# Access values with State.STATE_IDLE, etc.
12341235

12351236
func _ready():
12361237
# Access values with Name.KEY, prints '5'
12371238
print(State.STATE_JUMP)
12381239
# Use constant dictionary functions
12391240
# prints '["STATE_IDLE", "STATE_JUMP", "STATE_SHOOT"]'
12401241
print(State.keys())
1242+
# prints '["STATE_IDLE", "STATE_JUMP", "STATE_SHOOT"]'
1243+
print(State)
1244+
# prints '[0, 5, 6]'
1245+
print(State.values())
12411246

12421247

12431248
Functions

0 commit comments

Comments
 (0)