unc prefix(<wbr>_:)</a>
        
<div class="comment collapse" id="comment-func-prefix_"><div class="p">
    <p>Returns a subsequence, up to the specified maximum length, containing the
initial elements of the sequence.</p>

<p>If the maximum length exceeds the number of elements in the sequence,
the result contains all the elements in the sequence.</p>

<pre><code class="language-swift">let numbers = [1, 2, 3, 4, 5]
print(numbers.prefix(2))
// Prints &quot;[1, 2]&quot;
print(numbers.prefix(10))
// Prints &