Hacker News new | past | comments | ask | show | jobs | submit login

> Is there some kind of embedded DSL stuff going on here?

Exactly. It's a (at this point, unofficial) Swift feature called "function builders." The types end up being the same, because the conditionals are represented as wrapper types.

So

    if count == 0 {
      EmptyView()
    } else {
      Text("\(count)")
    }
would result in a type something like `Conditional<EmptyView, Text>`.

https://github.com/apple/swift-evolution/blob/9992cf3c11c2d5...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: