Skip to content

Commit

Permalink
Merge pull request #131 from Dean-Coakley/patch-1
Browse files Browse the repository at this point in the history
Fix substr docs and var names
  • Loading branch information
technosophos authored Feb 12, 2019
2 parents b70dc08 + d581f80 commit b1fe275
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion docs/strings.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ The above returns `hellohellohello`
Get a substring from a string. It takes three parameters:

- start (int)
- length (int)
- end (int)
- string (string)

```
Expand Down
14 changes: 7 additions & 7 deletions strings.go
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,17 @@ func splitn(sep string, n int, orig string) map[string]string {

// substring creates a substring of the given string.
//
// If start is < 0, this calls string[:length].
// If start is < 0, this calls string[:end].
//
// If start is >= 0 and length < 0, this calls string[start:]
// If start is >= 0 and end < 0, this calls string[start:]
//
// Otherwise, this calls string[start, length].
func substring(start, length int, s string) string {
// Otherwise, this calls string[start, end].
func substring(start, end int, s string) string {
if start < 0 {
return s[:length]
return s[:end]
}
if length < 0 {
if end < 0 {
return s[start:]
}
return s[start:length]
return s[start:end]
}

0 comments on commit b1fe275

Please sign in to comment.