2 ms·
As demonstrated by other commenters, makes for a terse iterator-ish pattern in languages without iterators (like C, or until recently Javascript) e.g. whil
by masklinn 9y ago
As demonstrated by other commenters, makes for a terse iterator-ish pattern in languages without iterators (like C, or until recently Javascript) e.g.
while ((c = getchar()) != EOF) {
//
}
in a language with iterators would be
for (c in chars()) {
//
}
- masklinn 9y agoAnd note that this C pattern only works when you can pass the "end of iteration" signal in-band, if you can't you will need to use more complex pseudo-iteration protocols e.g. while(generator(&c)) { // }