Is there some flow operator to make this less verb...
# coroutines
l
Is there some flow operator to make this less verbose?:
Copy code
val response = readPacketFlow().first { response -> response is Acknowledgement }
when (response) {
	Acknowledgement -> true
	else -> false
}
Edit: I would like to return true or false from flow if the first item matches a given predicate.
o
I think that codepiece isn't correct. Response can never be anything other than Acknowledgment, because if the flow cant find Acknowledgment, it will throw an exception
So response is of type Acknowledgment
l
True. I would like to return true or false from flow if the first item matches a given predicate. So if the first item is not of type
Acknowledgement
, it should return false
I guess this would be my best option:
Copy code
return when (readPacketFlow().first()) {
	Acknowledgement -> true
	else -> false
}
­čĹŹ 1
t
return readPacketFlow().first() is Acknowledgement
Ô׼ 2