- StringNames are immutable strings designed for general-purpose representation of unique names (also called “string interning”).
- Two StringNames with the same value are the same object.
- Comparing them is extremely fast compared to regular Strings.
String ←> StringName conversion
Godot will tend to convert automatically between String and StringName
You will usually pass a String to methods expecting a StringName and it will be automatically converted (often at compile time), but in rare cases you can construct a StringName ahead of time with the StringName constructor or, in GDScript, the literal syntax
&"example"
. Manually constructing a StringName allows you to control when the conversion from String occurs or to use the literal and prevent conversions entirely.
StringName literals
To use a StringName literal attach &
before a string literal.