Skip to content

Commit

Permalink
1 array element missed
Browse files Browse the repository at this point in the history
In this example
`var s = "www.google.com".toSlice();`
`    var delim = ".".toSlice();`
`    var parts = new string[](s.count(delim) + 1);`

parts should contain three elements `www` / `google` / `com` but there are only two dots in `www.google.com` string.
(count + 1) is required instead of (count) if we want all three parts of the string to be in `parts` array.
  • Loading branch information
Dexaran authored May 29, 2017
1 parent b6d4970 commit 7846ccc
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ After the above code executes, `s` is now "bar baz", and `foo` is now "foo".
### Splitting a string into an array
var s = "www.google.com".toSlice();
var delim = ".".toSlice();
var parts = new string[](s.count(delim));
var parts = new string[](s.count(delim) + 1);
for(uint i = 0; i < parts.length; i++) {
parts[i] = s.split(delim).toString();
}
Expand Down

0 comments on commit 7846ccc

Please sign in to comment.