Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
StringName¶
A built-in type for unique strings.
Description¶
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.
You will usually just pass a String to methods expecting a StringName and it will be automatically converted, but you may occasionally want to construct a StringName ahead of time with the StringName constructor or, in GDScript, the literal syntax &"example"
.
See also NodePath, which is a similar concept specifically designed to store pre-parsed scene tree paths.
All of String's methods are available in this class too. They convert the StringName into a string, and they also return a string. This is highly inefficient and should only be used if the string is desired.
Note: In a boolean context, a StringName will evaluate to false
if it is empty (StringName("")
). Otherwise, a StringName will always evaluate to true
. The not
operator cannot be used. Instead, is_empty should be used to check for empty StringNames.
Constructors¶
StringName ( ) |
|
StringName ( StringName from ) |
|
StringName ( String from ) |
Methods¶
begins_with ( String text ) const |
|
bigrams ( ) const |
|
bin_to_int ( ) const |
|
c_escape ( ) const |
|
c_unescape ( ) const |
|
capitalize ( ) const |
|
casecmp_to ( String to ) const |
|
dedent ( ) const |
|