1
0
mirror of https://github.com/golang/go synced 2024-11-18 07:24:45 -07:00
go/src/strings
Alberto Donizetti 3a27f28e9b strings: document Split{,N,After,AfterN} edge cases
Apparently people get confused by the fact that

  Split("", ",")

returns []{""} instead of []{}.

This is actually just a consequence of the fact that if the separator
sep (2nd argument) is not found the string s (1st argument), then the
Split* functions return a length 1 slice with the string s in it.

Document the general case: if sep is not in s, what you get is a len 1
slice with s in it; unless both s and sep are "", in that case you get
an empty slice of length 0.

Fixes #19726

Change-Id: I64c8220b91acd1e5aa1cc1829199e0cd8c47c404
Reviewed-on: https://go-review.googlesource.com/44950
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2017-06-06 15:48:54 +00:00
..
compare_test.go
compare.go
example_test.go
export_test.go
reader_test.go
reader.go
replace_test.go
replace.go
search_test.go
search.go
strings_amd64.go
strings_decl.go
strings_generic.go
strings_s390x.go
strings_test.go
strings.go strings: document Split{,N,After,AfterN} edge cases 2017-06-06 15:48:54 +00:00
strings.s