str in Int(str) }
// [1, 2, nil, nil, 5]

let compactMapped: [Int] = possibleNumbers.compactMap { str in Int(str) }
// [1, 2, 5]
</code></pre>
<ul>
<li>Parameter transform: A closure that accepts an element of this
sequence as its argument and returns an optional value.</li>
</ul>
<blockquote>
<p>Complexity:
O(<em>m</em> + <em>n</em>), where <em>n</em> is the length of this sequence and <em>m</em> is the length of the result.</p>
</blockquote>
<h4>Declaration</h4><code class="language-swift">@inlinable publ