Skip to content

Instantly share code, notes, and snippets.

@nh7a
Created March 3, 2022 19:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nh7a/037b2162b54016052a19df4bfbc1c726 to your computer and use it in GitHub Desktop.
Save nh7a/037b2162b54016052a19df4bfbc1c726 to your computer and use it in GitHub Desktop.
public protocol WithConfigurable {}
public extension WithConfigurable where Self: AnyObject {
@discardableResult
func with(block: (Self) -> Void) -> Self {
block(self)
return self
}
}
extension NSObject: WithConfigurable {}
// let lbl = UILabel().with {
// $0.text = "yes"
// $0.textColor = .red
// }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment