RuneIterator provides no way to determine if moveNext() fails due to reaching the end of the string or if the string iterated upon is empty #10594
Labels
area-core-library
SDK core library issues (core, async, ...); use area-vm or area-web for platform specific libraries.
core-n
library-core
P2
A bug or feature request we're likely to work on
type-enhancement
A request for a change that isn't a bug
This issue was originally filed by bord...@gmail.com
I've been trying to use RuneIterator as the basis for a small parsing library. However the main impediment I've run into is determining throughout the parser whether r.moveNext() return false because the string i'm parsing is empty or if it returns false due to hitting end of string. My main source of frustration is that RuneIterator.rawindex is null is both cases which seems a bit odd. I would assume that in the end of string case the RuneIterator.rawindex would remain at (String.length - 1) or increment to String.length if moveNext() == false.
main() {
RuneIterator r = "a".runes.iterator;
print (r.current); // null
print (r.rawIndex); // null
while(r.moveNext()) {
print (r.current); // 97
print (r.rawIndex); // 0
}
print (r.current); // null
print (r.rawIndex); // null
print (r.moveNext()); // false
RuneIterator empty = "".runes.iterator;
print (empty.current); // null
print (empty.rawIndex); // null
print (empty.moveNext()); // false
}
The text was updated successfully, but these errors were encountered: