# SwiftUI @ViewBuilder Result is a TupleView, How is Apple Using It And Able to Avoid Turning Things Into AnyVIew?

**URL:** <https://forums.swift.org/t/swiftui-viewbuilder-result-is-a-tupleview-how-is-apple-using-it-and-able-to-avoid-turning-things-into-anyview/28181>\
**Category:** Using Swift\
**Tags:** off-topic\
**Created:** [August 23, 2019, 7:22pm UTC](https://forums.swift.org/t/swiftui-viewbuilder-result-is-a-tupleview-how-is-apple-using-it-and-able-to-avoid-turning-things-into-anyview/28181 "2019-08-23T19:22:05Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![artyom-stv](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/artyom-stv/32/9380_2.png) [@artyom-stv](https://forums.swift.org/u/artyom-stv)\
**Post date:** [October 28, 2019, 10:04am UTC](https://forums.swift.org/t/swiftui-viewbuilder-result-is-a-tupleview-how-is-apple-using-it-and-able-to-avoid-turning-things-into-anyview/28181/4 "2019-10-28T10:04:26Z")

</div>

`ViewBuilder` is a function builder.

`ViewBuilder`-based closure `content` may produce any kind of views. If there are two or more subviews, it produces a `TupleView`:

```swift
HStack {
    Text("a")
    Text("b")
}

```

If there are no subviews, it produces an `EmptyView`:

```swift
HStack {
}

```

The best place to read about function builders is the original [proposal](https://github.com/apple/swift-evolution/blob/9992cf3c11c2d5e0ea20bee98657d93902d5b174/proposals/XXXX-function-builders.md). But there are also many articles about function builders including [this answer](https://stackoverflow.com/questions/56434549/what-enables-swiftuis-dsl) on [stackoverflow.com](http://stackoverflow.com).

The implementation of `ViewBuilder` looks like this:

```swift
@_functionBuilder
public struct ViewBuilder {
    @_alwaysEmitIntoClient
    public static func buildBlock() -> EmptyView {
        .init()
    }

    @_alwaysEmitIntoClient
    public static func buildBlock<Content>(_ content: Content) -> Content where Content: View {
        content
    }

    @_alwaysEmitIntoClient
    public static func buildIf<Content>( _ content: Content?) -> Content? where Content: View {
        content
    }

    @_alwaysEmitIntoClient
    public static func buildEither<TrueContent, FalseContent>(
        first: TrueContent) -> _ConditionalContent<TrueContent, FalseContent>
        where TrueContent: View, FalseContent: View
    {
        .init(storage: .trueContent(first))
    }

    @_alwaysEmitIntoClient
    public static func buildEither<TrueContent, FalseContent>(
        second: FalseContent) -> _ConditionalContent<TrueContent, FalseContent>
        where TrueContent: View, FalseContent: View
    {
        .init(storage: .falseContent(second))
    }

    @_alwaysEmitIntoClient
    public static func buildBlock<C0, C1>(
        _ c0: C0,
        _ c1: C1) -> TupleView<(C0, C1)>
        where C0: View, C1: View
    {
        .init((c0, c1))
    }

    @_alwaysEmitIntoClient
    public static func buildBlock<C0, C1, C2>(
        _ c0: C0,
        _ c1: C1,
        _ c2: C2) -> TupleView<(C0, C1, C2)>
        where C0: View, C1: View, C2: View
    {
        .init((c0, c1, c2))
    }

    // ...
}

```

---

_[View the full topic](https://forums.swift.org/t/swiftui-viewbuilder-result-is-a-tupleview-how-is-apple-using-it-and-able-to-avoid-turning-things-into-anyview/28181)._
