|
|
|
|
|
by poikroequ
659 days ago
|
|
A bit of a contrived example, but something like this (two for statements): [x*y for x in range (10) for y in range(10)] It's not often, but occasionally there are moments where I'm writing code in Kotlin and wish I could use a list comprehension. I do prefer Kotlin overall, but there's a few things that I think would be "nice to have" from Python. Especially the yield keyword, such a wonderful way to write your own iterators. |
|
On the other hand, you're not limited to for loops/ifs inside such a generator, but can use fairly arbitrary control flow.