Avatar ·

What does the `some` keyword mean in Swift and SwiftUI?

Hi! I started learning Swift and SwiftUI, and I keep coming across the strange word `some` in View declarations. For example, here's standard code: ```swift struct ContentView: View { var body: some View { Text("Hello, world!") } } ``` I understand that `var body: some View` is a property that returns some kind of View. But why is `some` needed here? Why can't we just write `var body: View`? I tried removing `some`, and Xcode gives an error: "Protocol 'View' can only be used as a generic constraint because it has Self or associated type requirements". What does that mean? I read Apple's documentation, but it's written in a complicated way: "opaque return type", "existential type"... Can you explain in simple terms why this keyword is needed, when to use it, and how it works?