Avatar
@swift-5.3.3 enum Either<R, L> { case right(R) case left(L) } @_functionBuilder struct Expression { public static func buildIf<C>(_ c: C?) -> C? { c } public static func buildEither<T, F>(first: T) -> Either<T, F> { .right(first) } public static func buildEither<T, F>(second: F) -> Either<T, F> { .left(second) } } func exp<T>(@Expression f: () -> T) -> T { f() } let a = exp { if true { "" } else { 1 } } print(type(of: a))