News for hackers. Stuff that matters.
Re:A deep dive into Swift’s function builders by dwaite on Friday September 25, 2020 @12:29AM (#24586597)
In other languages, the builder pattern usually consists of just methods on a builder object that manipulate internal state until you 'build' an instance. Function builders on the other hand support building of a strong type.

The builder can convert expressions into components that are then assembled into results. Some applications want to be able to represent the result as a strong generic type.

As an example of this, imagine

  if let releaseName = releaseName {
     Div("Release \(releaseName)")
  else {
     Blink("Prerelease")
  }
might be captured by such a builder as an Either<Div, Blink>.

There are no comments on this comment yet.