Why not multi for?


Hi all,

Minor question.

It might be good to have a shortcut for:

for (i in 1..10)
         for (j in 1..10)


for (i in 1..10, j in 1..10)


I’m not sure I like this. The key thing here is that i and j don’t loop independently, rather that j is looped inside the i loop (for a total of 100 iterations). This syntax hides that and certainly doesn’t help learnability (for beginners, not experienced developers in other languages). If you really want to

for (i in 1..10) for (j in 1..10)

Is valid Kotlin, It’s ugly though.


Yes, I am actually thought about something like list comprehensions (like in Erlang or Haskell).