Where is the String interpolation from "Structure your app for SwiftUI previews" documented?

I'd never seen this before. (This is an image I can't upload.)

How are you supposed to format this?

Code Block swift
Text(
  """
  \(
    { var nameComponents = PersonNameComponents()
      nameComponents.givenName = "Given"
      nameComponents.familyName = "Family"
      return nameComponents as NSPersonNameComponents
    } (),
    formatter: {
      let formatter = PersonNameComponentsFormatter()
      formatter.style = .long
      return formatter
    } ()
  )
  """
)


If you’re referring to the \(..., formatter: ...) interpolation syntax, this is one of the overloads of SwiftUI.LocalizedStringKey.StringInterpolation.appendInterpolation. Each of the overloads on that page is a different way you can use string interpolation in a localized SwiftUI string.

If you’re referring to the { ... }() syntax used for the parameters, that’s actually just a closure that gets called immediately after it’s formed. It’s a trick folks use to group together several statements into a single expression.

If you’re referring to the ””” syntax, that’s a multiline string literal. There’s a section about them in The Swift Programming Language.

The whole thing put together is just a combination of many slightly unusual language features.
Where is the String interpolation from "Structure your app for SwiftUI previews" documented?
 
 
Q