Is there a more Kotlin-like way to do this? ``` p...
# codereview
b
Is there a more Kotlin-like way to do this?
Copy code
private fun <
        NumberType : Number,
        PointType : ComputablePoint<NumberType>,
        SegmentType : ComputableLineSegment<NumberType, PointType>
        >
        ComputableSize<NumberType>.randomPointNotOnPath(path: ComputablePath<NumberType, PointType, SegmentType>, maxAttempts: Integer = 100)
        : Point<NumberType> {

    var point = randomPoint
    for (i in 1..maxAttempts) {
        if (path.contains(point)) {
            point = randomPoint
        } else {
            break
        }
    }
    return point
}
Full source: https://github.com/BlueHuskyStudios/Snek/blob/095c97c6a1fb108d2638df0ab54c9630e67fa529/JVM/src/org/bh/game/snek/io/SnekDataGenerator.kt#L42-L58