+ 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 Answers
+ 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š