classref: Sync with current master branch (42c7f14)

This commit is contained in:
Godot Organization
2025-06-07 03:33:02 +00:00
parent 365ca84c14
commit f9f2c80955
1011 changed files with 7431 additions and 4600 deletions

View File

@@ -677,7 +677,7 @@ Returns the index of the **first** occurrence of ``what`` in this string, or ``-
.. code-tab:: gdscript
print("Team".find("I")) # Prints -1
print("Potato".find("t")) # Prints 2
print("Potato".find("t", 3)) # Prints 4
print("Potato".find("t", 5)) # Prints -1
@@ -685,7 +685,7 @@ Returns the index of the **first** occurrence of ``what`` in this string, or ``-
.. code-tab:: csharp
GD.Print("Team".Find("I")); // Prints -1
GD.Print("Potato".Find("t")); // Prints 2
GD.Print("Potato".Find("t", 3)); // Prints 4
GD.Print("Potato".Find("t", 5)); // Prints -1
@@ -725,7 +725,7 @@ Formats the string by replacing all occurrences of ``placeholder`` with the elem
# Prints "Waiting for Godot is a play by Samuel Beckett, and Godot Engine is named after it."
var use_array_values = "Waiting for {0} is a play by {1}, and {0} Engine is named after it."
print(use_array_values.format(["Godot", "Samuel Beckett"]))
# Prints "User 42 is Godot."
print("User {id} is {name}.".format({"id": 42, "name": "Godot"}))
@@ -808,7 +808,7 @@ If the string is a valid file name or path, returns the file extension without t
var b = "cool.txt".get_extension() # b is "txt"
var c = "cool.font.tres".get_extension() # c is "tres"
var d = ".pack1".get_extension() # d is "pack1"
var e = "file.txt.".get_extension() # e is ""
var f = "file.txt..".get_extension() # f is ""
var g = "txt".get_extension() # g is ""
@@ -1037,7 +1037,7 @@ Returns ``true`` if all characters of this string can be found in ``text`` in th
::
var text = "Wow, incredible!"
print("inedible".is_subsequence_of(text)) # Prints true
print("Word!".is_subsequence_of(text)) # Prints true
print("Window".is_subsequence_of(text)) # Prints false
@@ -1126,7 +1126,7 @@ If ``with_prefix`` is ``true``, the hexadecimal number needs to prefixed by ``"0
print("A08E".is_valid_hex_number()) # Prints true
print("-AbCdEf".is_valid_hex_number()) # Prints true
print("2.5".is_valid_hex_number()) # Prints false
print("0xDEADC0DE".is_valid_hex_number(true)) # Prints true
.. rst-class:: classref-item-separator
@@ -1239,14 +1239,14 @@ Returns the concatenation of ``parts``' elements, with each element separated by
.. code-tab:: gdscript
var fruits = ["Apple", "Orange", "Pear", "Kiwi"]
print(", ".join(fruits)) # Prints "Apple, Orange, Pear, Kiwi"
print("---".join(fruits)) # Prints "Apple---Orange---Pear---Kiwi"
.. code-tab:: csharp
string[] fruits = ["Apple", "Orange", "Pear", "Kiwi"];
// In C#, this method is static.
GD.Print(string.Join(", ", fruits)); // Prints "Apple, Orange, Pear, Kiwi"
GD.Print(string.Join("---", fruits)); // Prints "Apple---Orange---Pear---Kiwi"
@@ -1441,11 +1441,11 @@ Trailing zeros are not included in the string. The last digit is rounded, not tr
String.num(3.141593) # Returns "3.141593"
String.num(3.141593, 3) # Returns "3.142"
String.num(3.14159300) # Returns "3.141593"
# Here, the last digit will be rounded up,
# which reduces the total digit count, since trailing zeros are removed:
String.num(42.129999, 5) # Returns "42.13"
# If `decimals` is not specified, the maximum number of significant digits is 14:
String.num(-0.0000012345432123454321) # Returns "-0.00000123454321"
String.num(-10000.0000012345432123454321) # Returns "-10000.0000012345"
@@ -1725,7 +1725,7 @@ If ``maxsplit`` is greater than ``0``, the number of splits may not exceed ``max
var some_string = "One,Two,Three,Four"
var some_array = some_string.rsplit(",", true, 1)
print(some_array.size()) # Prints 2
print(some_array[0]) # Prints "One,Two,Three"
print(some_array[1]) # Prints "Four"
@@ -1856,7 +1856,7 @@ If ``maxsplit`` is greater than ``0``, the number of splits may not exceed ``max
.. code-tab:: gdscript
var some_array = "One,Two,Three,Four".split(",", true, 2)
print(some_array.size()) # Prints 3
print(some_array[0]) # Prints "One"
print(some_array[1]) # Prints "Two"
@@ -1866,7 +1866,7 @@ If ``maxsplit`` is greater than ``0``, the number of splits may not exceed ``max
// C#'s `Split()` does not support the `maxsplit` parameter.
var someArray = "One,Two,Three".Split(",");
GD.Print(someArray[0]); // Prints "One"
GD.Print(someArray[1]); // Prints "Two"
GD.Print(someArray[2]); // Prints "Three"
@@ -2244,14 +2244,14 @@ Encodes the string to URL-friendly format. This method is meant to properly enco
var prefix = "$DOCS_URL/?highlight="
var url = prefix + "Godot Engine:docs".uri_encode()
print(url) # Prints "$DOCS_URL/?highlight=Godot%20Engine%3%docs"
.. code-tab:: csharp
var prefix = "$DOCS_URL/?highlight=";
var url = prefix + "Godot Engine:docs".URIEncode();
GD.Print(url); // Prints "$DOCS_URL/?highlight=Godot%20Engine%3%docs"
@@ -2360,7 +2360,7 @@ Formats the **String**, replacing the placeholders with one or more parameters.
::
print("I caught %d fishes!" % 2) # Prints "I caught 2 fishes!"
var my_message = "Travelling to %s, at %2.2f km/h."
var location = "Deep Valley"
var speed = 40.3485
@@ -2479,6 +2479,7 @@ Returns ``true`` if the left **String** comes after ``right`` in `Unicode order
Returns a new **String** that only contains the character at ``index``. Indices start from ``0``. If ``index`` is greater or equal to ``0``, the character is fetched starting from the beginning of the string. If ``index`` is a negative value, it is fetched starting from the end. Accessing a string out-of-bounds will cause a run-time error, pausing the project execution if run from the editor.
.. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
.. |required| replace:: :abbr:`required (This method is required to be overridden when extending its base class.)`
.. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
.. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
.. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`