summaryrefslogtreecommitdiff
path: root/doc/classes/String.xml
diff options
context:
space:
mode:
Diffstat (limited to 'doc/classes/String.xml')
-rw-r--r--doc/classes/String.xml37
1 files changed, 34 insertions, 3 deletions
diff --git a/doc/classes/String.xml b/doc/classes/String.xml
index 0376a3f96e..de9eb518c6 100644
--- a/doc/classes/String.xml
+++ b/doc/classes/String.xml
@@ -181,7 +181,17 @@
<method name="get_extension" qualifiers="const">
<return type="String" />
<description>
- If the string is a valid file path, returns the extension.
+ Returns the extension without the leading period character ([code].[/code]) if the string is a valid file name or path. If the string does not contain an extension, returns an empty string instead.
+ [codeblock]
+ print("/path/to/file.txt".get_extension()) # "txt"
+ print("file.txt".get_extension()) # "txt"
+ print("file.sample.txt".get_extension()) # "txt"
+ print(".txt".get_extension()) # "txt"
+ print("file.txt.".get_extension()) # "" (empty string)
+ print("file.txt..".get_extension()) # "" (empty string)
+ print("txt".get_extension()) # "" (empty string)
+ print("".get_extension()) # "" (empty string)
+ [/codeblock]
</description>
</method>
<method name="get_file" qualifiers="const">
@@ -229,7 +239,7 @@
<method name="is_absolute_path" qualifiers="const">
<return type="bool" />
<description>
- If the string is a path to a file or directory, returns [code]true[/code] if the path is absolute.
+ Returns [code]true[/code] if the string is a path to a file or directory and its starting point is explicitly defined. This includes [code]res://[/code], [code]user://[/code], [code]C:\[/code], [code]/[/code], etc.
</description>
</method>
<method name="is_empty" qualifiers="const">
@@ -241,7 +251,7 @@
<method name="is_rel_path" qualifiers="const">
<return type="bool" />
<description>
- If the string is a path to a file or directory, returns [code]true[/code] if the path is relative.
+ Returns [code]true[/code] if the string is a path to a file or directory and its starting point is implicitly defined within the context it is being used. The starting point may refer to the current directory ([code]./[/code]), or the current [Node].
</description>
</method>
<method name="is_subsequence_of" qualifiers="const">
@@ -410,6 +420,21 @@
<argument index="0" name="number" type="float" />
<argument index="1" name="decimals" type="int" default="-1" />
<description>
+ Converts a [float] to a string representation of a decimal number.
+ The number of decimal places can be specified with [code]decimals[/code]. If [code]decimals[/code] is [code]-1[/code] (default), decimal places will be automatically adjusted so that the string representation has 14 significant digits (counting both digits to the left and the right of the decimal point).
+ Trailing zeros are not included in the string. The last digit will be rounded and not truncated.
+ Some examples:
+ [codeblock]
+ String.num(3.141593) # "3.141593"
+ String.num(3.141593, 3) # "3.142"
+ String.num(3.14159300) # "3.141593", no trailing zeros.
+ # Last digit will be rounded up here, which reduces total digit count since
+ # trailing zeros are removed:
+ String.num(42.129999, 5) # "42.13"
+ # If `decimals` is not specified, the total amount of significant digits is 14:
+ String.num(-0.0000012345432123454321) # "-0.00000123454321"
+ String.num(-10000.0000012345432123454321) # "-10000.0000012345"
+ [/codeblock]
</description>
</method>
<method name="num_scientific" qualifiers="static">
@@ -621,6 +646,12 @@
Returns the similarity index of the text compared to this string. 1 means totally similar and 0 means totally dissimilar.
</description>
</method>
+ <method name="simplify_path" qualifiers="const">
+ <return type="String" />
+ <description>
+ Returns a simplified canonical path.
+ </description>
+ </method>
<method name="split" qualifiers="const">
<return type="PackedStringArray" />
<argument index="0" name="delimiter" type="String" />