diff options
| author | Andrew Gerrand <adg@golang.org> | 2010-07-27 15:06:08 +1000 |
|---|---|---|
| committer | Andrew Gerrand <adg@golang.org> | 2010-07-27 15:06:08 +1000 |
| commit | 8b821696cc96ea3167c16138beff9ca1ecc5f1ed (patch) | |
| tree | b124c28a227b2ca798cdebe52d31662db0a66386 /src/pkg/strings/strings.go | |
| parent | 88fc337fa2ae0f3de4616fac46d8e9fc7e22026d (diff) | |
| download | go-8b821696cc96ea3167c16138beff9ca1ecc5f1ed.tar.xz | |
bytes, strings: mention the n < 0 case in Split/SplitAfter doc comment
R=r, rsc
CC=golang-dev
https://golang.org/cl/1669055
Diffstat (limited to 'src/pkg/strings/strings.go')
| -rw-r--r-- | src/pkg/strings/strings.go | 22 |
1 files changed, 14 insertions, 8 deletions
diff --git a/src/pkg/strings/strings.go b/src/pkg/strings/strings.go index 925566c744..12be04c239 100644 --- a/src/pkg/strings/strings.go +++ b/src/pkg/strings/strings.go @@ -163,16 +163,22 @@ func genSplit(s, sep string, sepSave, n int) []string { return a[0 : na+1] } -// Split splits the string s around each instance of sep, returning an array of substrings of s. -// If sep is empty, Split splits s after each UTF-8 sequence. -// If n >= 0, Split splits s into at most n substrings; the last substring will be the unsplit remainder. -// Thus if n == 0, the result will be nil. +// Split slices s into substrings separated by sep and returns a slice of +// the substrings between those separators. +// If sep is empty, Split splits after each UTF-8 sequence. +// The count determines the number of substrings to return: +// n > 0: at most n substrings; the last substring will be the unsplit remainder. +// n == 0: the result is nil (zero substrings) +// n < 0: all substrings func Split(s, sep string, n int) []string { return genSplit(s, sep, 0, n) } -// SplitAfter splits the string s after each instance of sep, returning an array of substrings of s. -// If sep is empty, SplitAfter splits s after each UTF-8 sequence. -// If n >= 0, SplitAfter splits s into at most n substrings; the last substring will be the unsplit remainder. -// Thus if n == 0, the result will be nil. +// SplitAfter slices s into substrings after each instance of sep and +// returns a slice of those substrings. +// If sep is empty, Split splits after each UTF-8 sequence. +// The count determines the number of substrings to return: +// n > 0: at most n substrings; the last substring will be the unsplit remainder. +// n == 0: the result is nil (zero substrings) +// n < 0: all substrings func SplitAfter(s, sep string, n int) []string { return genSplit(s, sep, len(sep), n) } |
