https://kotlinlang.org logo
Title
m

marcinmoskala

11/21/2017, 2:31 PM
This is why I am always doing like that:
fun bestStudents(allStudents: List<Student>) = allStudents
        .sortedBy { it.grade }
        .take(10)
y

yole

11/27/2017, 4:49 PM
not sure what your point is. the style guide talks about 4 spaces for expression body and 4 spaces for chained call, so you won’t get the extreme indents shown in your first example. as for not wrapping immediately after the
=
sign, we discussed that and found that a small expression chunk after a long function signature is really hard to see and can obscure the meaning of the code
m

marcinmoskala

11/29/2017, 5:44 AM
I agree that it is easy to miss first chain block after long function definition. This formatting should be good if it will be automatic
fun bestStudents(allStudents: List<Student>) = 
    allStudents
        .sortedBy { it.grade }
        .take(10)