From 49b3281d13b6bb295104657d8e73421be9d367dd Mon Sep 17 00:00:00 2001 From: Lexyth Date: Wed, 19 Mar 2025 00:09:04 +0100 Subject: [PATCH] Update Enum names, improve enum member names, and add related suggestion - Changed the grammatical number of all enum names to be singular. - Removed the enum names from their members, (e.g.: Tile.TILE_BRICK -> Tile.BRICK). - Added a suggestion for the reader to use singular case for enum names. --- .../gdscript/gdscript_styleguide.rst | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tutorials/scripting/gdscript/gdscript_styleguide.rst b/tutorials/scripting/gdscript/gdscript_styleguide.rst index 6230736eab4..03a397d83b8 100644 --- a/tutorials/scripting/gdscript/gdscript_styleguide.rst +++ b/tutorials/scripting/gdscript/gdscript_styleguide.rst @@ -186,11 +186,11 @@ indentation level to distinguish continuation lines: "Job": "Mechanic", } - enum Tiles { - TILE_BRICK, - TILE_FLOOR, - TILE_SPIKE, - TILE_TELEPORT, + enum Tile { + BRICK, + FLOOR, + SPIKE, + TELEPORT, } **Bad**: @@ -211,11 +211,11 @@ indentation level to distinguish continuation lines: "Job": "Mechanic", } - enum Tiles { - TILE_BRICK, - TILE_FLOOR, - TILE_SPIKE, - TILE_TELEPORT, + enum Tile { + BRICK, + FLOOR, + SPIKE, + TELEPORT, } Trailing comma @@ -738,7 +738,7 @@ underscore (\_) to separate words: const MAX_SPEED = 200 -Use PascalCase for enum *names* and CONSTANT\_CASE for their members, as they +Use PascalCase for enum *names* and keep them singular, as they represent a type. Use CONSTANT\_CASE for their members, as they are constants: :: @@ -872,7 +872,7 @@ variables, in that order. signal player_spawned(position) - enum Jobs { + enum Job { KNIGHT, WIZARD, ROGUE, @@ -882,7 +882,7 @@ variables, in that order. const MAX_LIVES = 3 - @export var job: Jobs = Jobs.KNIGHT + @export var job: Job = Job.KNIGHT @export var max_health = 50 @export var attack = 5