Does Swift have an “or equals” function like ||= in Ruby?
<p>In Swift, how do I set an optional <code>foo</code> but only if it's <code>nil</code>?</p>

<p>I know about <a href="https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/BasicOperators.html#//apple_ref/doc/uid/TP40014097-CH6-ID72" rel="noreferrer">Swift's nil coalescing operator</a>:</p>

<p><code>foo = foo ?? "Hello"</code> (where <code>foo</code> is an optional <code>String</code>)</p>

<p>But, is there a better way, like in Ruby?</p>

<p><code>foo ||= "Hello"</code></p>