Closed
Description
In some cases it would be useful to know the current position within the string as you go through the codepoints (for example, to store it and use later for slicing or error reporting).
To achieve this, .codePoints()
iterator could yield pairs [position, codePoint]
instead of just codePoint
.
The obvious downside is that this would be inconsistent with the default chars iterator.
On the other hand, with regular chars iterator, this can be done in a more or less obvious manner already (you can sum up char.length
as you go through the string), and, if not, we can add an extra method to yield [position, char]
pairs too in future if required.
Thoughts?
Metadata
Metadata
Assignees
Labels
No labels