As SwiftUI View body attribute has a opaque type 'some View' so it should not allow two concrete types to be returned. But in my case, it's not giving error.
struct TestOneView: View {
var body: some View {
if 1 != 1 {
Text("Text")
} else {
Color.blue
}
}
}
Now if I change this code to below one, It gives error as expected.
struct TestOneView: View {
var body: some View {
if 1 != 1 {
return Text("Text")
} else {
return Color.blue
}
}
}
This code gives error 'Function declares an opaque return type 'some View', but the return statements in its body do not have matching underlying types'
Please guide.