2 ms·
agreed, i use while very rarely in any language. iterating lists is really the main use of looping, so some form of for-each is my preferred tool. even when a t
by em-bee 2y ago
agreed, i use while very rarely in any language. iterating lists is really the main use of looping, so some form of for-each is my preferred tool. even when a traditional for loop is better, my first instinct is to try for-each first. it's a pity that javascript's forEach is so awkward to use, needing a callback. i remember when pike's foreach was extended from only handling arrays to also supporting mappings and anything else iterable, it felt like a massive improvement. go's for/range syntax is a bit different, but it does the job. i could not ask for anything more.