Hello Kotlin experts, I am trying to obtain the re...
# announcements
v
Hello Kotlin experts, I am trying to obtain the result from a
flatMap -> comparator
. please see the gist at https://gist.github.com/visakha/8ac7f823e02192beb23a3f869fc4a196
i
So, what is your question? Do you have some problem with that code? Or do you want to know, how to make it more idiomatic in Kotlin?
v
@ilya.gorbunov I want to have this side effect of updating the reason4Pick attribute, so I can run the jUnit assert
so far, I could not figure the reason, or what rule was winning
i
If
maxRating
is a Car, could you just set its
reasonForPick
before returing?
v
yes it should be called maxRatingOrLowerMileage, that name would be more approp for that val, however, how could I know if maxRating or lowerMileage was the reason
i
Oh, you can check if there are several items with the same max rating. If there're more than one, then the decision was made based on mileage.
if (v1.count { it.rating == maxRating.rating } > 1)
v
Thank you, I will check that, but since I have about 70% java projects and 30%Kotlin projects, I am trying to stick with Java 8 streams std lib, so the knowledge is transferable between.