I would like the following "pseudocode" to be valid syntax (but clearly it’s not) :
minDistance = minOf(myLocations.forEach{return location.distanceTo(it)})
To clarify, I am trying to find the distance from the smartphone (location) to the closest location in a mutable list of locations (myLocations).
Does Kotlin allow this level of terseness, or must I break it up in a few more lines and help variables?
>Solution :
I believe this is what you’re looking for
minDistance = myLocations.minOf { location.distanceTo(it) }