Closed Bug 926685 Opened 13 years ago Closed 12 years ago

ForOfIterator comment is out of date

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: jorendorff, Unassigned)

References

Details

The comment on ForOfIterator in jsiter.h says: > * Convenience class for imitating a JS level for-of loop. Typical usage: > * > * ForOfIterator it(cx); > * if (!it.init(iterable)) > * return false; > * RootedValue val(cx); > * for (;;) { > * if (!next(&val, &done)) > * return false; > * if (!DoStuff(cx, val)) > * return false; > * } > * Unfortunately it is not that simple. Real usage is like this: ForOfIterator it(cx); if (!it.init(iterable)) return false; RootedValue val(cx); bool done; for (;;) { if (!next(&val, &done)) return false; if (done) break; if (!DoStuff(cx, val)) return false; } The comment should be fixed. Ideally the API could be streamlined: ForOfIterator it(cx); if (!it.first(iterable)) return false; while (!it.done) { if (!DoStuff(cx, it.value)) return false; if (!it.next()) return false; }
Assignee: general → nobody
This got fixed in bug 952873.
Status: NEW → RESOLVED
Closed: 12 years ago
Depends on: 952873
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.