title: Returning optionals from a method
body: <p>I have a basic set of constructs, including a <code>Garage</code> struct to define a car garage, a <code>Garages</code> class to encapsulate a hardcoded list of garages, and a <code>Car</code> class that searches the garages based on a manufacturer String.</p>
  
  <p>My issue is that the <code>Car.findGarageByManufacturer</code> needs to optionally return a <code>Garage</code> instance (returning <code>nil</code> if it's not found).` But I'm given the following error:</p>
  
  <p><strong>Value of optional type "Garage?" not unwrapped; did you mean to use '!' or '?' ?</strong></p>
  
  <p>...on the line <code>return foundGarage</code></p>
  
  <p>How do you return optionals inside of a method?</p>
  
  <pre><code>// Using a struct because an 'Object' type doesn't seem to exist :-/
  struct Garage {
      var name: String
      var manu: String
  }
  
  // Hardcorded set of garages, using class to test returning an array of a struct instance.
  class Garages {
      func getGarages() -&gt; Array&lt;Garage&gt; {
          var garages: Garage[] = [
              Garage(name: "VW Car Park", manu: "VW"),
              Garage(name: "Williams BMW", manu: "BMW"),
              Garage(name: "Hadwins", manu: "VW")
          ]
          return garages;
      }
  }
  
  // Immediately create an instance of the Garages class
  let garages = Garages()
  
  class Car {
      func findGarageByManufacturer(manufacturer: String) -&gt; Garage {
          var foundGarage: Garage? = nil
          for garage in garages.getGarages() {
              if(garage.manu == manufacturer) {
                  foundGarage = garage
              }
          }
          // This is the line that's causing an error
          // How do we optionally return a garage?
          return foundGarage
      }
  }
  </code></pre>