What is the different singleOrNull and find
Sun, May 8, 2016Although I believe that singleOrNull and find proviedes the same function was different.
>> listOf(1,2,3).singleOrNull { it > 0 }
null
>>> listOf(1,2,3).find { it > 0 }
1
The following is the same result
>>> listOf(1,2,3).singleOrNull { it == 1 }
1
>>> listOf(1,2,3).find { it == 1 }
1