title: How to use Guard when the function expect return value
body: <p>I am a fan of the <a href="https://developer.apple.com/library/content/documentation/Swift/Conceptual/Swift_Programming_Language/Statements.html" rel="nofollow noreferrer" title="Guard"><code>guard</code></a> statements using Swift.</p>
  
  <p>One thing I haven't fully understand is how (or even if) to use it inside a <code>func</code>tion that expect return value. </p>
  
  <p>Simple example:</p>
  
  <pre><code>func refreshAudioMix() -&gt; AVPlayerItem? {
     guard let originalAsset = rootNC.lastAssetLoaded else {
           return nil
     }
     let asset = originalAsset.copy() as! AVAsset
     ..... return AVPlayerItem ....
  }
  </code></pre>
  
  <p>The issue with this approach is that I need to check the returned value each time. I am trying to understand if am I approaching this correctly or maybe even <code>guard</code> not needed here at all.</p>
  
  <p><strong>Thank you!</strong></p>