|
|
|
|
|
by hughesjj
652 days ago
|
|
It's mostly ease of semantics -- in your example you use two layers of map and as a result need to do flatMap instead of just map twice In py, for list/set/dictionary/generator comprehensions, the format is always the same and always the same as if you were to do it as a normal nested loop, save for the statement being first instead of last (you can also do filters using normal if statement syntax, these go at the end/after all your loops). I actually like statement first because it gets to the "meat" of the semantics before the context (which loop etc), but end do the day it's all a bit arbitrary @ yield, there's literally no difference between Python and kotlin. Python also offers a generator comprehension, which is nice, but it has nothing to do with yield i_am_a_generator = (
x+1
for x in range(10*100)
) |
|