Given function: ```fun constructFlow() = flow { fo...
# coroutines
c
Given function:
Copy code
fun constructFlow() = flow { for(x in channel) emit(x) }
Is there any practical difference between
Copy code
val someFlow = constructFlow()
and
Copy code
val someFlow get() = constructFlow()
? I do realize, that second version will call constructFlow on every access, while first one - only once. But since a flow is only a definition of what should happen after collection - isn`t it always the same?
z
no practical difference, definitely no difference in behavior
e
if there's some external state like
Copy code
fun constructFlow: Flow<Int> {
    var x = 0
    return flow { emit(++x) }
}
then they might behave differently, but in your case it looks like it would have the same effect either way
c
thanks 🙂