Comments
Part of the Fundamentals section of Coddy's GDScript journey. Lesson 3 of 92.
Comments are notes you write inside your code. GDScript ignores them: they are there to help people read the code.
A comment starts with #. Everything after # on that line is ignored:
# This is a comment
print("Hello!")A comment can also follow code on the same line:
print("Hello!") # This prints Hello!GDScript has no special syntax for multi-line comments. Start each line with #:
# This program greets the player.
# It runs once, at the start.
print("Welcome!")A comment can also disable a line of code without deleting it:
# print("This line does NOT run")
print("This line runs")An indented block cannot be empty. If you comment out every line under func _ready():, add pass, a statement that does nothing, so the block still has a line to run.
Challenge
BeginnerThe program prints two lines. Turn the line that prints Goodbye! into a comment, so the program prints only:
Hello!Do not delete the line: put # in front of it.
Try it yourself
extends Node
func _ready():
print("Hello!")
print("Goodbye!")
This lesson includes a short quiz. Start the lesson to answer it and track your progress.
All lessons in Fundamentals
4Operators Part 1
Arithmetic OperatorsInteger DivisionModulo OperatorArithmetic ShortcutsRecap - Simple MathComparison Operators10Functions
Declare a FunctionArgumentsReturnReturn TypesRecap - Sigma FunctionRecap - Validation FunctionDefault Values5Operators Part 2
Logical Operators Part 1Logical Operators Part 2Recap - Simple LogicLogical Operators Part 3Ternary OperatorPractice on your own: Online GDScript compiler