title: Using a ViewController variable in segue.destination
body: <p>In the code below, I'm trying to use the variable <code>controller</code> to fill in the type of my destination segue at the bottom. But instead I get an error message that says <code>controller</code> is undeclared. It's declared right there on the second line! I can see it! I realize there are many alternatives to using segue identifiers but I'm more interested in learning why this doesn't work.</p>
  
  <pre><code>override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
      var controller: UIViewController
  
      switch segue.identifier {
      case "ASegue":
          controller = AViewController()
      case "BSegue":
          controller = BViewController()
      case "CSegue":
          controller = CViewController()
      default:
          controller = AViewController()
      }
  
      if let vc = segue.destination as? controller { //Use of undeclared type 'controller'
          ...
      }
  }
  </code></pre>