0
struct ContentView: View {

    var body: some View {
        Text("Hello")
        Text("World")
    }
}

The preview shows the first text field but not the second. They'll both appear if they're contained in a stack.

var f: Bool {
   true
   false
}

This results in the compiler complaining about a missing return in function - a single bool value is ok.

So, why are two views ok but not two bools? Is it a quirk of the view builder?

Ian Warburton
  • 15,170
  • 23
  • 107
  • 189
  • 1
    `View` is an element of SwiftUI and uses a special DSL: https://stackoverflow.com/questions/56434549/what-enables-swiftuis-dsl – Martin R Aug 08 '20 at 15:55
  • 1
    Yes, it is an effect of ViewBuilder. Btw, you have rather two previews, just scroll canvas down. – Asperi Aug 08 '20 at 15:57

0 Answers0