Answer the question
In order to leave comments, you need to log in
Produce{} vs iterator{}?
I read that these two functions work similarly, the difference is only in the name of the methods and the scope, channels are used in coroutines, and the iterator is outside. But they didn’t write there how to pass a value using an iterator, I google and find only the iterator () method for collections and its application, but that’s not it. So I can create an instance of Channel () put a value in it, and output it somewhere, but how do I do the same with an iterator? What should I instantiate in order to do the same action and put a value in yield() and pull it out via next()?
Answer the question
In order to leave comments, you need to log in
Nothing, iterator is a top-level builder. Have you tried writing code, or are you just reading this crap?
iterator {
yield(1)
yield(2)
yield(3)
}.forEach { i -> print(i) }
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question