When i try to run break statement in default case, it doesn't run and shows 'Closure containing control flow statement cannot be used with result builder 'ViewBuilder'' error.Why it doesn't run and how to solve this trouble?
Hello @Frknakts,
In a result builder, all branches of a switch statement need to produce a value of the type that the result builder expects. In this case, it is a SwiftUI ViewBuilder, and so each branch of the switch must produce a View.
Instead of breaking in the default case, provide a default View value, for example, Text("My Default View")
.
For greater detail about using switch statements within a result builder, see https://github.com/swiftlang/swift-evolution/blob/main/proposals/0289-result-builders.md.
Best regards,
Greg