how does one do flow1.collect and flow2.collect in...
# coroutines
j
how does one do flow1.collect and flow2.collect in unison to combine right and left halves?
d
flow1.zip(flow2) { a, b -> value }
?
j
the example delays creep me out a bit, but ok, i see that's viable, thanks!
d
Either
zip
or
combine
, depending on your needs.
j
the flows are Array<*>, they don't like plus ....
🤔 1
previsouly, before the zip, these were promoted to list.
Copy code
Error:(333, 48) Kotlin: Cannot choose among the following candidates without completing type inference: 
public operator fun <T> Array<Any?>.plus(element: Any?): Array<Any?> defined in kotlin.collections
public operator fun <T> Array<Any?>.plus(elements: Array<out Any?>): Array<Any?> defined in kotlin.collections
is this a bug or a designed safety feature?
d
You should specify the type on
a
and
b
explicitly to help the compiler here
j
i have been wrestling with this for days, the only thing that gets me out of it is promoting to List<Any?>
im thinking maybe just bake in system.arraycopy, because elegant
a
@jimn You can specify exactly which of the
plus
implementations you need. In this case it is
a.plus(elements = b)
j
SO has a thing, the spread operator is way cheaper. seems to be