+ 6

Kotlin- When minOrNull() returns null?

var arr= arrayOf(1,2,3) print(arr.minOrNull()) The output is 1. When will the minOrNull() extension return null?🤔

21st May 2021, 8:36 AM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar
2 Antworten
+ 3
minOrNull() returns null when collection/array is empty https://kotlinlang.org/docs/collection-aggregate.html ""' minOrNull() and maxOrNull() return the smallest and the largest element respectively. On empty collections, they return null. ""'
21st May 2021, 8:41 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
+ 3
22nd May 2021, 6:42 AM
Muhd Khairul Amirin
Muhd Khairul Amirin - avatar