TL;DR: Use var for properties in struct as long as it serves as a nominal tuple. In most cases, there is no obvious benefit to using let for struct properties.
Let's start with a simple example:
struct MyStruct {| struct ContentView: View { | |
| @State var togglePreview = false | |
| var body: some View { | |
| VStack { | |
| URLPreview(previewURL: URL(string: "https://medium.com")!, togglePreview: $togglePreview) | |
| .aspectRatio(contentMode: .fit) | |
| .padding() | |
| } | |
| //------------------------------------------------------------------------ | |
| // The SwiftUI Lab: Advanced SwiftUI Animations | |
| // https://swiftui-lab.com/swiftui-animations-part1 (Animating Paths) | |
| // https://swiftui-lab.com/swiftui-animations-part2 (GeometryEffect) | |
| // https://swiftui-lab.com/swiftui-animations-part3 (AnimatableModifier) | |
| //------------------------------------------------------------------------ | |
| import SwiftUI | |
| struct ContentView: View { | |
| { | |
| // Use IntelliSense to learn about possible attributes. | |
| // Hover to view descriptions of existing attributes. | |
| // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | |
| "version": "0.2.0", | |
| "configurations": [ | |
| { | |
| "type": "lldb", | |
| "name": "LLDB", | |
| "cwd" : "${workspaceFolder}", |