diff options
author | kobewi <kobewi4e@gmail.com> | 2021-10-31 15:36:16 +0100 |
---|---|---|
committer | kobewi <kobewi4e@gmail.com> | 2021-11-02 11:24:07 +0100 |
commit | e5725c7debd025be9f7b475527324b4b934fed58 (patch) | |
tree | e495b253462623e64525f8eb6bc908f76165356f /doc | |
parent | d6f972fad45d28222b1437a047241dd74f0d5b90 (diff) | |
download | redot-engine-e5725c7debd025be9f7b475527324b4b934fed58.tar.gz |
Expose String.get_slice
Diffstat (limited to 'doc')
-rw-r--r-- | doc/classes/String.xml | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/doc/classes/String.xml b/doc/classes/String.xml index abb68e0d05..bd94065db1 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -200,6 +200,19 @@ If the string is a valid file path, returns the filename. </description> </method> + <method name="get_slice" qualifiers="const"> + <return type="String" /> + <argument index="0" name="delimiter" type="String" /> + <argument index="1" name="slice" type="int" /> + <description> + Splits a string using a [code]delimiter[/code] and returns a substring at index [code]slice[/code]. Returns an empty string if the index doesn't exist. + This is a more performant alternative to [method split] for cases when you need only one element from the array at a fixed index. + Example: + [codeblock] + print("i/am/example/string".get_slice("/", 2)) # Prints 'example'. + [/codeblock] + </description> + </method> <method name="hash" qualifiers="const"> <return type="int" /> <description> @@ -676,6 +689,7 @@ <description> Splits the string by a [code]delimiter[/code] string and returns an array of the substrings. The [code]delimiter[/code] can be of any length. If [code]maxsplit[/code] is specified, it defines the number of splits to do from the left up to [code]maxsplit[/code]. The default value of [code]0[/code] means that all items are split. + If you need only one element from the array at a specific index, [method get_slice] is a more performant option. Example: [codeblocks] [gdscript] |