-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Fixes #7507 #7521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes #7507 #7521
Conversation
If it is empty, return the original string.
|
Supersedes: #7509 |
|
|
||
| doAssert "a largely spaced sentence".split(" ", maxsplit=1) == @["a", " largely spaced sentence"] | ||
| doAssert(sep.len > 0) | ||
| if sep.len == 0: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
perform this check in splitCommon, also make sure that rsplit has the same.
|
Copying @GULPF's comment here:
Wouldn't it be a better idea to follow one of these examples instead of coming up with yet a different behaviour? |
|
Relevant IRC discussion: https://irclogs.nim-lang.org/06-04-2018.html#09:18:39 |
|
We need to decide how to handle this. @Araq wants it to be a no op, I think adopting Python's semantics is a good idea (principle of least surprise and all that :)). |
|
ok, so do it Python's way. Modify |
|
FYI Python does not handle split and replace consistently either. |
|
Fixed it differently. |
|
Relevant commit: 5d13e3f |
Add check if
subinreplaceorsepinsplitis an empty string. If it is empty, return the original string.Fixes #7507.