Skip to content

Instantly share code, notes, and snippets.

@mehmetfarhan
Created July 7, 2020 07:47
Show Gist options
  • Save mehmetfarhan/52d90069b97fdf5fc19295563e65859a to your computer and use it in GitHub Desktop.
Save mehmetfarhan/52d90069b97fdf5fc19295563e65859a to your computer and use it in GitHub Desktop.
Buildable
public protocol Buildable { }
public extension Buildable where Self: AnyObject {
func with<T>(
_ property: ReferenceWritableKeyPath<Self, T>,
_ value: T
) -> Self {
self[keyPath: property] = value
return self
}
}
extension NSObject: Buildable { }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment