Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
go
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
go
Commits
8b821696
Commit
8b821696
authored
Jul 27, 2010
by
Andrew Gerrand
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bytes, strings: mention the n < 0 case in Split/SplitAfter doc comment
R=r, rsc CC=golang-dev
https://golang.org/cl/1669055
parent
88fc337f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
17 deletions
+28
-17
src/pkg/bytes/bytes.go
src/pkg/bytes/bytes.go
+14
-9
src/pkg/strings/strings.go
src/pkg/strings/strings.go
+14
-8
No files found.
src/pkg/bytes/bytes.go
View file @
8b821696
...
...
@@ -179,17 +179,22 @@ func genSplit(s, sep []byte, sepSave, n int) [][]byte {
return
a
[
0
:
na
+
1
]
}
// Split splits the array s around each instance of sep, returning an array of subarrays of s.
// If sep is empty, Split splits s after each UTF-8 sequence.
// If n >= 0, Split splits s into at most n subarrays; the last subarray will contain an unsplit remainder.
// Thus if n == 0, the result will be nil.
// Split slices s into subslices separated by sep and returns a slice of
// the subslices between those separators.
// If sep is empty, Split splits after each UTF-8 sequence.
// The count determines the number of subslices to return:
// n > 0: at most n subslices; the last subslice will be the unsplit remainder.
// n == 0: the result is nil (zero subslices)
// n < 0: all subslices
func
Split
(
s
,
sep
[]
byte
,
n
int
)
[][]
byte
{
return
genSplit
(
s
,
sep
,
0
,
n
)
}
// SplitAfter splits the array s after each instance of sep, returning an array of subarrays of s.
// If sep is empty, SplitAfter splits s after each UTF-8 sequence.
// If n >= 0, SplitAfter splits s into at most n subarrays; the last subarray will contain an
// unsplit remainder.
// Thus if n == 0, the result will ne nil.
// SplitAfter slices s into subslices after each instance of sep and
// returns a slice of those subslices.
// If sep is empty, Split splits after each UTF-8 sequence.
// The count determines the number of subslices to return:
// n > 0: at most n subslices; the last subslice will be the unsplit remainder.
// n == 0: the result is nil (zero subslices)
// n < 0: all subslices
func
SplitAfter
(
s
,
sep
[]
byte
,
n
int
)
[][]
byte
{
return
genSplit
(
s
,
sep
,
len
(
sep
),
n
)
}
...
...
src/pkg/strings/strings.go
View file @
8b821696
...
...
@@ -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
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment