updated method
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
e34f8f0ed8
commit
48a84960f4
@ -12,12 +12,10 @@ public protocol Initable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
extension Withable where Self:Initable {
|
extension Withable where Self:Initable {
|
||||||
/// Provides a closure to configure instances inline.
|
|
||||||
/// - Parameter closure: A closure with a mutable copy of `self` as the argument.
|
/// Construct a new instance, setting an arbitrary subset of properties
|
||||||
/// - Returns: Simply returns the mutated copy of the instance after called the `closure`.
|
public init(with closure: (inout Self) -> Void) {
|
||||||
@discardableResult public static func initWith(_ closure: (_ instance: inout Self) -> Void) -> Self {
|
self.init()
|
||||||
var copy = Self()
|
closure(&self)
|
||||||
closure(©)
|
|
||||||
return copy
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user