I have list of Location. Something like this:
[{"latitude": "45.42123", "longitude": "44.32132", "speed": 4.3}, {"latitude": "46.212", "longitude": "45.4334", "speed": 5.2}]
We have extensions in Kotlin so i can easily get max value of speed like this:
myList.maxOf { it.speed }
But how can i get average value of speed?
P.S. i found the same question in Java. I need solution in Kotlin.
Try this:
val average = myList.map { it.speed }.average()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With