Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions tutorials/scripting/gdscript/gdscript_basics.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1231,13 +1231,18 @@ a dictionary can also be used with a named enum.

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

func _ready():
# Access values with Name.KEY, prints '5'
print(State.STATE_JUMP)
# Use constant dictionary functions
# prints '["STATE_IDLE", "STATE_JUMP", "STATE_SHOOT"]'
print(State.keys())
# prints '["STATE_IDLE", "STATE_JUMP", "STATE_SHOOT"]'
print(State)
Comment on lines +1242 to +1243
Copy link
Member

@timothyqiu timothyqiu Dec 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait...

This is not true. State is a Dictionary so it should print { "STATE_IDLE": 0, "STATE_JUMP": 5, "STATE_SHOOT": 6 }. Or it should be print(State.keys()) instead.

# prints '[0, 5, 6]'
print(State.values())

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should I restore the whitespace here? If yes, should I place it between the below print statements so they aren't a united codeblock?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put it after the last line of code, keep two lines before "Functions", easier to read


Functions
Expand Down