Avatar
omochimetaru 4/5/2021 7:33 AM
あ、これaも推論させてるからそうだね
7:36 AM
extension ViewBuilder { public static func buildEither<TrueContent, FalseContent>(first: TrueContent) -> _ConditionalContent<TrueContent, FalseContent> where TrueContent : View, FalseContent : View public static func buildEither<TrueContent, FalseContent>(second: FalseContent) -> _ConditionalContent<TrueContent, FalseContent> where TrueContent : View, FalseContent : View } https://yanamura.hatenablog.com/entry/2019/09/05/150849
potatotips #64でLTした内容です。 SwiftUIのViewで条件によってViewをだしわけたいことがたまにあるかと思います。 SwiftUIでこのように条件によってViewを出し分けるようなコードを書いてみます。 var body: some View { if imageName.isEmpty { return Text("no image") } else { return Image(imageName) } } そうするとこのようなコンパイルエラーになってしまいます。 ! Function declares an opaque return type, but the…
7:36 AM
できることは間違いない。