Merge pull request #28648 from KoBeWi/substr-1
Make second parameter of substr optional
This commit is contained in:
commit
2b52cd3e5c
4 changed files with 7 additions and 4 deletions
|
|
@ -2331,6 +2331,9 @@ String String::insert(int p_at_pos, const String &p_string) const {
|
|||
}
|
||||
String String::substr(int p_from, int p_chars) const {
|
||||
|
||||
if (p_chars == -1)
|
||||
p_chars = length() - p_from;
|
||||
|
||||
if (empty() || p_from < 0 || p_from >= length() || p_chars <= 0)
|
||||
return "";
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue