</p>

<pre><code class="language-swift">let numbers = [3, 7, 4, -2, 9, -6, 10, 1]
let positivePrefix = numbers.prefix(while: { $0 &gt; 0 })
// positivePrefix == [3, 7, 4]</code></pre>

<p>If <code>predicate</code> matches every element in the sequence, the resulting
sequence contains every element of the sequence.</p>

<p><strong><code>predicate</code>:</strong>  A closure that takes an element of the sequence as
  its argument and returns a Boolean value indicating whether the
  element should be included 