As SwiftUI View physique attribute has a opaque kind ‘some View’ so it mustn’t enable two concrete varieties to be returned. However in my case, it is not giving error.
struct TestOneView: View {
var physique: some View {
if 1 != 1 {
Textual content("Textual content")
} else {
Colour.blue
}
}
}
Now if I alter this code to under one, It offers error as anticipated.
struct TestOneView: View {
var physique: some View {
if 1 != 1 {
return Textual content("Textual content")
} else {
return Colour.blue
}
}
}
This code offers error ‘Operate declares an opaque return kind ‘some View’, however the return statements in its physique should not have matching underlying varieties’
Please information.