singleOrNull () usulidan foydalanishingiz mumkin , nullagar oqim bo'sh bo'lsa yoki oqimda bir nechta element bo'lsa, qaytadi .
1
2018-05-01 xoxlasa buladi 121 2
3
4
5
6
7
sakkiz
to'qqiz
o'n
o'n bir
|
import kotlinx.coroutines.flow.*
suspend fun main(){
val userFlow = listOf("Tom", "Bob").asFlow()
val singleUser = userFlow.singleOrNull()
if(singleUser!=null)
println("Single User: $singleUser")
else
println("Not found")
|
Do'stlaringiz bilan baham: |