I am not entirely sure that what I think is the problem actually it. But I am trying to use lazy as a delegate and I am getting compiler errors
data class Geocode(var latitude: Double, var longitude: Double) : Comparable<Geocode> {
override fun compareTo(other: Geocode): Int {
var result = this.latitude.compareTo(other.latitude)
if (result == 0)
result = this.longitude.compareTo(other.longitude)
return result
}
}
data class HubKt(val position:Geocode) {
}
data class Example(val hubs:Collection<HubKt>) {
val bounds:Any by lazy {
object {
val ne: this.hubs.map { h -> h.position }.max()
val sw: this.hubs.map { h -> h.position }.min()
}
}
}
if this were java, I would want the bounds function to return a map:
public Map<String,Geocode> getBounds() {
Geocode ne = geos.stream().max(Geocode::compareTo).get();
Geocode sw = geos.stream().min(Geocode::compareTo).get();
return ImmutableMap.of("ne",ne,"sw",sw);
}
I think the problem is not using the correct this. I tried this@Authenticate and it's a no go. Hell, I might even be over complicating it. Thanks for the insight.