title: Is it possible to pass an argument into a sequence function?
body: <p>I'm looking for a way to pass an argument into a Kotlin sequence function similar to how it works in JS:</p>
  <pre class="lang-js prettyprint-override"><code> function *gen () {
       console.log(yield) // prints 1
       console.log(yield) // prints 2
   }
      
   const it = gen()
      
   it.next()  // first iteration will execute the first yield and pause
   it.next(1) // we pass 1 to the first yield which will be printed
   it.next(2) // we pass 2 to the second yield which will be printed
  </code></pre>
  <p>Something like this in Kotlin:</p>
  <pre class="lang-kotlin prettyprint-override"><code>fun main() {
      val it = gen().iterator()
  
      // Iterator#next() doesn't expect an argument
      it.next(1) 
      it.next(2)
  }
  
  fun gen() = sequence {
      println(yield(null)) // Would print 1
      println(yield(null)) // Would print 2
  }
  </code></pre>