Learn Courses My Dashboard

Declaring an array

var body: some View {

    var textDeck = ["1","2"]
    var textTest: [String]
    var textCard:String = ""

What am I missing? Xcode doesn’t like the textTest declaration, but it is ok with the textDeck…

“Closure containing a declaration cannot be used with result builder ‘ViewBuilder’”
Xcode Version 13.1 (13A1030d)

Thanks
Monty

Don’t declare variables inside a SwiftUI View's body property.

The difference between textTest and the other two is that the other two are assigned values and textTest gets just a type declaration.