See all glossary terms

Annotation

An annotation is an extra piece of information or metadata included in code that provides the computer or the user with more information about how the code works.
In the GDScript language, annotations start with an @ sign and are used to change the behavior of the following code statement.
For example, the @onready annotation makes the initialization of a member variable run right before the _ready() function. And the @export annotation and its many variants make a property editable in the Inspector dock in the editor.
So, the following code:
@onready var label: Label = $Label
Is nearly equivalent to the following:
var label: Label = null

func _ready() -> void:
    label = $Label
The nuance is that the @onready annotation makes the initialization of the label variable run right before the _ready() function. In practice, it's the same as inserting the initialization code at the beginning of the _ready() function.
Can I create my own annotations in GDScript?
At the time of writing, Godot does not support creating custom annotations in the GDScript language. There's a proposal to add this feature, but the discussion is not settled yet.