title: Alternative to switch statement in SwiftUI ViewBuilder block?
body: <p>⚠️ <strong>23 June 2020 Edit: From Xcode 12, both switch and if let statements will be supported in the ViewBuilder!</strong></p>
  <p>I’ve been trying to replicate an app of mine using SwiftUI. It has a RootViewController which, depending on an enum value, shows a different child view controller. As in SwiftUI we use views instead of view controllers, my code looks like this:</p>
  <pre class="lang-swift prettyprint-override"><code>struct RootView : View {
     @State var containedView: ContainedView = .home
  
     var body: some View {
        // custom header goes here
        switch containedView {
           case .home: HomeView()
           case .categories: CategoriesView()
           ...
        }
     }
  }
  </code></pre>
  <p>Unfortunately, I get a warning:</p>
  <blockquote>
  <p><em>Closure containing control flow statement cannot be used with function builder <code>ViewBuilder</code></em>.</p>
  </blockquote>
  <p>So, are there any alternatives to switch so I can replicate this behaviour?</p>