2019-12-01a few seconds read (About 97 words)How to make init with closure in SwiftIssue #526 1234567public class Build: UsesXcodeBuild { public var arguments = [String]() public init(_ closure: (Build) -> Void = { _ in }) { closure(self) }} Use function builder12345678910111213141516171819202122232425262728public class Workflow { public var workingDirectory: String = "." public let tasks: [Task] public init(@TaskBuilder builder: () -> [Task]) { self.tasks = builder() self.tasks.forEach { task in task.workflow = self } } public init(@TaskBuilder builder: () -> Task) { self.tasks = [builder()] self.tasks.forEach { task in task.workflow = self } }}public func run(@TaskBuilder builder: () -> [Task]) { let workflow = Workflow(builder: builder) workflow.run()}public func run(@TaskBuilder builder: () -> Task) { let workflow = Workflow(builder: builder) workflow.run()}#swift