Skip to content

Instantly share code, notes, and snippets.

@wilmarvh
Forked from krzyzanowskim/with.swift
Created May 20, 2019 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wilmarvh/3f7a5baeb0c5acea0e2433f1ef1d8815 to your computer and use it in GitHub Desktop.
Save wilmarvh/3f7a5baeb0c5acea0e2433f1ef1d8815 to your computer and use it in GitHub Desktop.
private func with<T: NSView>(_ value: T, _ builder: (T) -> Void) {
builder(value)
}
private func with<T: NSView>(_ value: T, _ builder: (T) throws -> Void) rethrows {
try builder(value)
}
// Use
with(self.collectionView) {
$0.dataSource = self
$0.delegate = self
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment