Tweak String.indexOf(_,_) a bit.

- Simplify the arithmetic a little in wrenStringFind().
- Allow the start to be negative.
- Even more tests.
- Docs.
This commit is contained in:
Bob Nystrom
2016-08-03 22:19:34 -07:00
parent e5dce527ac
commit 6845328661
9 changed files with 74 additions and 26 deletions
+9
View File
@@ -120,6 +120,15 @@ Returns the index of the first byte matching `search` in the string or `-1` if
It is a runtime error if `search` is not a string.
### **indexOf**(search, start)
Returns the index of the first byte matching `search` in the string or `-1` if
`search` was not found, starting a byte offset `start`. The start can be
negative to count backwards from the end of the string.
It is a runtime error if `search` is not a string or `start` is not an integer
index within the string's byte length.
### **iterate**(iterator), **iteratorValue**(iterator)
Implements the [iterator protocol](../../control-flow.html#the-iterator-protocol)