我目前有这样的代码:
if let isSaved = vm.place?.isSaved {
Text(isSaved ? "Saved" : "Want to go")
} else {
Text("Want to go")
}
我如何重写这段代码,以避免本质上必须两次使用Text
视图的"Want to Go"版本?
如果我试一试:
Text(vm.place?.isSaved ? "Saved" : "Want to go")
我得到的错误是:
可选类型‘Bool?’的值必须展开为"Bool"类型的值