I define a struct of OptionClosureView.
struct OptionClosureView<Content: View>: View {
var content: (()->Content)? = nil
var body: some View {
if content == nil{
Text("Hello, World!")
}else{
content!()
}
}
}
If I don't want to assign a value to the property of "content", I mean a default Text view for OptionClosureView. In this case, I just want to declare it as below:
OptionClosureView()
instead of:
OptionClosureView<Text>()
or
OptionClosureView<Image>()
or
....
IMO, I don't care what is "Content" standing for in this case. Is there any way to assign a default value to the generic parameter "Content" in order to allow me to invoke OptionClosureView() directly? Something like:
struct OptionClosureView<Content: View = Text>: View {
....
}