+ 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?🤔
2 ответов
+ 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.
""'
+ 3
Thank you 🇮🇳Omkar🕉