Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

4
  • I'm gonna have to reread several more times for all this to sink in but impressed by (a) the quality of the comments and (b) how quickly you whipped all this up! Thank you Commented Mar 20, 2022 at 23:51
  • 3
    Note that the official coding conventions say that a for loop is preferable to forEach unless you’re using it in a null-safe call or at the end of a chain of functional calls. Commented Mar 21, 2022 at 0:48
  • @Tenfour04 True, you are right, I actually wanted to show the use of forEachIndexed, but somehow forgot to do it and ended up with withIndex.forEach. Commented Mar 22, 2022 at 12:57
  • I think the same convention would mean for (x in y.withIndex()) would be preferable to forEachIndexed. Commented Mar 22, 2022 at 13:14