title: Understanding Kotlin's yield function
body: <p>I don't see a very clear definition of the <a href="https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.sequences/-sequence-scope/yield.html" rel="noreferrer"><code>yield</code></a> function in Kotlin. </p>
  
  <p>Example in the link above doesn't mention much but the following,</p>
  
  <pre><code>val sequence = sequence {
      val start = 0
      // yielding a single value
      yield(start)
      // yielding an iterable
      yieldAll(1..5 step 2)
      // yielding an infinite sequence
      yieldAll(generateSequence(8) { it * 3 })
  }
  
  println(sequence.take(7).toList()) // [0, 1, 3, 5, 8, 24, 72]
  </code></pre>
  
  <p>But the above example doesn't point out the significance of yield. </p>
  
  <ul>
  <li>What does it mean that it is a suspending function?</li>
  <li>In what scenarios can it be advantageous? </li>
  </ul>