From 8c2dc177b61e6c9bc1895a5046e229cad28052e5 Mon Sep 17 00:00:00 2001 From: Mateo Kuruk Miccino Date: Thu, 7 May 2020 15:53:49 -0300 Subject: [PATCH] GDScript: Add join method on String Docs: Add join on String.xml --- core/variant_call.cpp | 2 ++ doc/classes/String.xml | 13 +++++++++++++ 2 files changed, 15 insertions(+) diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 39bfd04a0b1..48c1c19f2f2 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -262,6 +262,7 @@ struct _VariantCall { VCALL_LOCALMEM3R(String, split); VCALL_LOCALMEM3R(String, rsplit); VCALL_LOCALMEM2R(String, split_floats); + VCALL_LOCALMEM1R(String, join); VCALL_LOCALMEM0R(String, to_upper); VCALL_LOCALMEM0R(String, to_lower); VCALL_LOCALMEM1R(String, left); @@ -1731,6 +1732,7 @@ void register_variant_methods() { ADDFUNC3R(STRING, PACKED_STRING_ARRAY, String, split, STRING, "delimiter", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0)); ADDFUNC3R(STRING, PACKED_STRING_ARRAY, String, rsplit, STRING, "delimiter", BOOL, "allow_empty", INT, "maxsplit", varray(true, 0)); ADDFUNC2R(STRING, PACKED_FLOAT32_ARRAY, String, split_floats, STRING, "delimiter", BOOL, "allow_empty", varray(true)); + ADDFUNC1R(STRING, STRING, String, join, PACKED_STRING_ARRAY, "parts", varray()); ADDFUNC0R(STRING, STRING, String, to_upper, varray()); ADDFUNC0R(STRING, STRING, String, to_lower, varray()); diff --git a/doc/classes/String.xml b/doc/classes/String.xml index a72b8f05d81..03f62732c44 100644 --- a/doc/classes/String.xml +++ b/doc/classes/String.xml @@ -837,6 +837,19 @@ Returns a copy of the string with characters removed from the right. + + + + + + + Return a [String] which is the concatenation of the [code]parts[/code]. The separator between elements is the string providing this method. + Example: + [codeblock] + print(", ".join(["One", "Two", "Three", "Four"])) + [/codeblock] + +