taer
05/28/2020, 8:14 PMfun concat(first: Flow<Int>, second: Flow<Int>): Flow<Int> = flow {
first.collect { value ->
return@collect emit(value)
}
second.collect { value ->
return@collect emit(value)
}
}
What is the point of the return@collect
?octylFractal
05/28/2020, 8:16 PMsecond.collect(value -> {
return emit.invoke(value);
});
but if that was not added, it would be
second.collect(value -> {
emit.invoke(value);
return Unit.INSTANCE;
});
which can potentially be less optimal I presumetaer
05/28/2020, 8:18 PMreturn@collect
it still works identically.octylFractal
05/28/2020, 8:19 PMCOROUTINE_SUSPENDED
. I recall seeing this kludge in the flow code somewhere, let me see if I can find ittaer
05/28/2020, 8:20 PMDominaezzz
05/28/2020, 8:22 PMtaer
05/28/2020, 8:23 PMtaer
05/28/2020, 8:24 PMoctylFractal
05/28/2020, 8:24 PMtaer
05/28/2020, 8:25 PMoctylFractal
05/28/2020, 8:25 PMtaer
05/28/2020, 8:26 PMoctylFractal
05/28/2020, 8:29 PMtaer
05/28/2020, 8:31 PM