bjonnh
04/03/2019, 9:54 PMDias
04/03/2019, 10:09 PMkevinmost
04/04/2019, 7:47 PMlen(name) for name in names
is just all over the place. You have to read the end of the line to understand what's going on at the front. Meanwhile, in Kotlin it's just:
names.map { name -> name.length }
and I feel like at no point in reading that line are you surprised by a variable you haven't seen at all in the pastkevinmost
04/04/2019, 7:49 PMlen(name) for name in names if len(name) % 2 == 0
it feels so weird that the subject variables are squished in the middle of the transform (on the left) and the predicate (on the right)
names.map { name -> name.length }.filter { name -> name.length % 2 == 0 }
reads sequentially, againkevinmost
04/04/2019, 7:49 PMsumBy
, sorted
, reduce
, etc), and lets you define your own operations that fit into the chain more fluentlyDias
04/04/2019, 8:55 PM[x*3 for x in list if x %2 == 0]
looks a lot nicer than
list(map(lambda x: x*3, filter(lambda f: f%2==0, list)))
Dias
04/04/2019, 8:59 PMkevinmost
04/04/2019, 9:19 PM