Browse Source

String.format() wrong placeholder syntax

From: `var string = "I have {} cats.".format([3])`
To: `var string = "I have {0} cats.".format([3])`
RazerTexz 5 months ago
parent
commit
820fdbe6b7
1 changed files with 1 additions and 1 deletions
  1. 1 1
      tutorials/scripting/gdscript/gdscript_format_string.rst

+ 1 - 1
tutorials/scripting/gdscript/gdscript_format_string.rst

@@ -6,7 +6,7 @@ GDScript format strings
 Godot offers multiple ways to dynamically change the contents of strings:
 Godot offers multiple ways to dynamically change the contents of strings:
 
 
 - Format strings: ``var string = "I have %s cats." % "3"``
 - Format strings: ``var string = "I have %s cats." % "3"``
-- The ``String.format()`` method: ``var string = "I have {} cats.".format([3])``
+- The ``String.format()`` method: ``var string = "I have {0} cats.".format([3])``
 - String concatenation: ``var string = "I have " + str(3) + " cats."``
 - String concatenation: ``var string = "I have " + str(3) + " cats."``
 
 
 This page explains how to use format strings, and briefly explains the ``format()``
 This page explains how to use format strings, and briefly explains the ``format()``