How to get the index in a for each loop? I want to print numbers for every second iteration
For example
for (value in collection) { if (iteration_no %
Ranges also lead to readable code in such situations:
(0 until collection.size step 2) .map(collection::get) .forEach(::println)