diff --git a/kotlin-native/performance/ring/src/main/kotlin/org/jetbrains/ring/GraphSolverBenchmark.kt b/kotlin-native/performance/ring/src/main/kotlin/org/jetbrains/ring/GraphSolverBenchmark.kt index 085da8659a5..202abbc1d24 100644 --- a/kotlin-native/performance/ring/src/main/kotlin/org/jetbrains/ring/GraphSolverBenchmark.kt +++ b/kotlin-native/performance/ring/src/main/kotlin/org/jetbrains/ring/GraphSolverBenchmark.kt @@ -33,7 +33,7 @@ class Greedy(private val graph: Graph) { val nodes = node.neighbors .filter { it.value != 0 && !visitedNodes.contains(it.key) } val clostest = nodes - .minBy { it.value }!! + .minByOrNull { it.value }!! return ClosestNode(clostest.key, clostest.value) } diff --git a/kotlin-native/samples/torch/src/torchMain/kotlin/ClassifierDemo.kt b/kotlin-native/samples/torch/src/torchMain/kotlin/ClassifierDemo.kt index 719deac00b5..0526a49cbfe 100644 --- a/kotlin-native/samples/torch/src/torchMain/kotlin/ClassifierDemo.kt +++ b/kotlin-native/samples/torch/src/torchMain/kotlin/ClassifierDemo.kt @@ -17,7 +17,7 @@ fun Float.toRoundedString(digits: Int = 0): String { fun Float.toPercentageString(roundToDigits: Int = 1) = (this * 100).toRoundedString(roundToDigits) -fun List.maxIndex() = withIndex().maxBy { it.value }!!.index +fun List.maxIndex() = withIndex().maxByOrNull { it.value }!!.index fun accuracy(predictionBatch: FloatMatrix, labelBatch: FloatMatrix): Float { val resultIndexes = predictionBatch.toList().map { it.maxIndex() }