@viewbuilder func applyif<t: view>(_ condition: bool, apply: (self) -> t) -> some view { if condition { apply(self) } else { self } } in swift

main.swift
@ViewBuilder
func applyIf<T: View>(_ condition: Bool, apply: (Self) -> T) -> some View {
    if condition {
        apply(self)
    } else {
        self
    }
}
162 chars
9 lines

related categories

gistlibby LogSnag