Merge pull request #61959 from timothyqiu/right-desc
Fix parameter name for `String.left` and `String.right`
This commit is contained in:
commit
abcbe36661
@ -3359,36 +3359,36 @@ String String::repeat(int p_count) const {
|
|||||||
return new_string;
|
return new_string;
|
||||||
}
|
}
|
||||||
|
|
||||||
String String::left(int p_pos) const {
|
String String::left(int p_len) const {
|
||||||
if (p_pos < 0) {
|
if (p_len < 0) {
|
||||||
p_pos = length() + p_pos;
|
p_len = length() + p_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_pos <= 0) {
|
if (p_len <= 0) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_pos >= length()) {
|
if (p_len >= length()) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
return substr(0, p_pos);
|
return substr(0, p_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
String String::right(int p_pos) const {
|
String String::right(int p_len) const {
|
||||||
if (p_pos < 0) {
|
if (p_len < 0) {
|
||||||
p_pos = length() + p_pos;
|
p_len = length() + p_len;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_pos <= 0) {
|
if (p_len <= 0) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (p_pos >= length()) {
|
if (p_len >= length()) {
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
return substr(length() - p_pos);
|
return substr(length() - p_len);
|
||||||
}
|
}
|
||||||
|
|
||||||
char32_t String::unicode_at(int p_idx) const {
|
char32_t String::unicode_at(int p_idx) const {
|
||||||
|
@ -356,8 +356,8 @@ public:
|
|||||||
int count(const String &p_string, int p_from = 0, int p_to = 0) const;
|
int count(const String &p_string, int p_from = 0, int p_to = 0) const;
|
||||||
int countn(const String &p_string, int p_from = 0, int p_to = 0) const;
|
int countn(const String &p_string, int p_from = 0, int p_to = 0) const;
|
||||||
|
|
||||||
String left(int p_pos) const;
|
String left(int p_len) const;
|
||||||
String right(int p_pos) const;
|
String right(int p_len) const;
|
||||||
String indent(const String &p_prefix) const;
|
String indent(const String &p_prefix) const;
|
||||||
String dedent() const;
|
String dedent() const;
|
||||||
String strip_edges(bool left = true, bool right = true) const;
|
String strip_edges(bool left = true, bool right = true) const;
|
||||||
|
@ -1402,8 +1402,8 @@ static void _register_variant_builtin_methods() {
|
|||||||
bind_method(String, to_upper, sarray(), varray());
|
bind_method(String, to_upper, sarray(), varray());
|
||||||
bind_method(String, to_lower, sarray(), varray());
|
bind_method(String, to_lower, sarray(), varray());
|
||||||
|
|
||||||
bind_method(String, left, sarray("position"), varray());
|
bind_method(String, left, sarray("length"), varray());
|
||||||
bind_method(String, right, sarray("position"), varray());
|
bind_method(String, right, sarray("length"), varray());
|
||||||
|
|
||||||
bind_method(String, strip_edges, sarray("left", "right"), varray(true, true));
|
bind_method(String, strip_edges, sarray("left", "right"), varray(true, true));
|
||||||
bind_method(String, strip_escapes, sarray(), varray());
|
bind_method(String, strip_escapes, sarray(), varray());
|
||||||
|
@ -412,9 +412,9 @@
|
|||||||
</method>
|
</method>
|
||||||
<method name="left" qualifiers="const">
|
<method name="left" qualifiers="const">
|
||||||
<return type="String" />
|
<return type="String" />
|
||||||
<argument index="0" name="position" type="int" />
|
<argument index="0" name="length" type="int" />
|
||||||
<description>
|
<description>
|
||||||
Returns a number of characters from the left of the string. If negative [code]position[/code] is used, the characters are counted downwards from [String]'s length.
|
Returns a number of characters from the left of the string. If negative [code]length[/code] is used, the characters are counted downwards from [String]'s length.
|
||||||
Examples:
|
Examples:
|
||||||
[codeblock]
|
[codeblock]
|
||||||
print("sample text".left(3)) #prints "sam"
|
print("sample text".left(3)) #prints "sam"
|
||||||
@ -599,9 +599,9 @@
|
|||||||
</method>
|
</method>
|
||||||
<method name="right" qualifiers="const">
|
<method name="right" qualifiers="const">
|
||||||
<return type="String" />
|
<return type="String" />
|
||||||
<argument index="0" name="position" type="int" />
|
<argument index="0" name="length" type="int" />
|
||||||
<description>
|
<description>
|
||||||
Returns a number of characters from the right of the string. If negative [code]position[/code] is used, the characters are counted downwards from [String]'s length.
|
Returns a number of characters from the right of the string. If negative [code]length[/code] is used, the characters are counted downwards from [String]'s length.
|
||||||
Examples:
|
Examples:
|
||||||
[codeblock]
|
[codeblock]
|
||||||
print("sample text".right(3)) #prints "ext"
|
print("sample text".right(3)) #prints "ext"
|
||||||
|
Loading…
Reference in New Issue
Block a user