Skip to content
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

strings: problem for strings.Split() #23534

Closed
iiinsomnia opened this issue Jan 24, 2018 · 1 comment
Closed

strings: problem for strings.Split() #23534

iiinsomnia opened this issue Jan 24, 2018 · 1 comment

Comments

@iiinsomnia
Copy link

if param s is an empty string, the result of strings.Split() should be an empty slice. But not now.

eg:

len(strings.Split("", ",")) // result: 1
@dominikh
Copy link
Member

Working as intended, and clearly documented:

If s does not contain sep and sep is not empty, Split returns a slice of length 1 whose only element is s.

Whether s itself is empty or not plays no role. This makes for a more robust API.

@mikioh mikioh changed the title problem for strings.Split() strings: problem for strings.Split() Jan 26, 2018
@golang golang locked and limited conversation to collaborators Jan 26, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants