Skip to content

Commit 7846ccc

Browse files
authoredMay 29, 2017
1 array element missed
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.
1 parent b6d4970 commit 7846ccc

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ After the above code executes, `s` is now "bar baz", and `foo` is now "foo".
3131
### Splitting a string into an array
3232
var s = "www.google.com".toSlice();
3333
var delim = ".".toSlice();
34-
var parts = new string[](s.count(delim));
34+
var parts = new string[](s.count(delim) + 1);
3535
for(uint i = 0; i < parts.length; i++) {
3636
parts[i] = s.split(delim).toString();
3737
}

0 commit comments

Comments
 (0)
Please sign in to comment.