❔ Does indexof search for the specified character at the specified index?
Or does it skip the specified index for the next?
12 Replies
It searches for the specific char and give it's index
yeah i know that. Thats not what im asking. Im asking at what index does the search begins
0
IndexOf
begins at 0 by default, but there is an overload which lets you specify which index to begin fromthinker227
REPL Result: Success
Result: int
Compile: 510.736ms | Execution: 26.074ms | React with ❌ to remove this embed.
thinker227
REPL Result: Success
Result: int
Compile: 437.160ms | Execution: 24.093ms | React with ❌ to remove this embed.
2
here specifies that the search should begin from index 2Ye you can provide the end index as well i.e till where tou want to search
(it's a count but yes)
thinker227
REPL Result: Success
Result: int
Compile: 460.137ms | Execution: 27.880ms | React with ❌ to remove this embed.
so if i put 2 as start index, it will also search the character at index 2 and not skip it and go to index 3
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.