title: `break` and `continue` in `forEach` in Kotlin
body: <p>Kotlin has very nice iterating functions, like <code>forEach</code> or <code>repeat</code>, but I am not able to make the <code>break</code> and <code>continue</code> operators work with them (both local and non-local):</p>
  
  <pre><code>repeat(5) {
      break
  }
  
  (1..5).forEach {
      continue@forEach
  }
  </code></pre>
  
  <p>The goal is to mimic usual loops with the functional syntax as close as it might be. It was definitely possible in some older versions of Kotlin, but I struggle to reproduce the syntax. </p>
  
  <p>The problem might be a bug with labels (M12), but I think that the first example should work anyway.</p>
  
  <p>It seems to me that I've read somewhere about a special trick/annotation, but I could not find any reference on the subject. Might look like the following:</p>
  
  <pre><code>public inline fun repeat(times: Int, @loop body: (Int) -&gt; Unit) {
      for (index in 0..times - 1) {
          body(index)
      }
  }
  </code></pre>