SwiftUI: Function declares an opaque return type, but has no return statements in its body from which to infer an underlying type

Function declares an opaque return type, but has no return statements in its body from which to infer an underlying type

When does such an error happen?

var body: some View {
Text("Hello, World!")
}
var body: some View {
let displayText = "Heyy Swifters !!"
Text(displayText)
}
var body: some View {
if isSwiftyDisplay {
Text("Heyy Swifters!!")
} else {
Text("Hello World!!")
}
}
@ViewBuilder
var
body: some View {
if isSwiftyDisplay {
Text("Heyy Swifters!!")
} else {
Text("Hello World!!")
}
}
var body: some View {
Text("Heyy Swifters!!")
Text("Hello World!!")
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store