I am trying to create an array which contains my struct Element. Trying to use .append I get two errors.
"Cannot use mutating member on immutable value: 'self' is immutable" and "Cannot convert value of type 'Element' to expected argument type '[Element]'"
I'm obviously doing this all wrong.
My test code:
var elements = [[Element]]()
var body: some View {
VStack {
ForEach (0..<26) { index in
Text("\(index) Hello, World!")
elements.append(Element(direction: "Direction \(index)", movement: "Movement \(index)", multiplier: index))
}
}
}
}
struct Element {
var direction: String
var movement: String
var multiplier: Int
}