We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Traditionally, from Swift 4.2 we need guard let self
guard let self
addButton.didTouch = { [weak self] in guard let self = self, let product = self.purchasedProduct() else { return self.delegate?.productViewController(self, didAdd: product) }
This is cumbersome, we can invent a higher order function to zip and unwrap the optionals
func with<A, B>(_ op1: A?, _ op2: B?, _ closure: (A, B) -> Void) { if let value1 = op1, let value2 = op2 { closure(value1, value2) } } addButton.didTouch = { [weak self] in with(self, self?.purchasedProduct()) { $0.delegate?.productViewController($0, didAdd: $1) } }
The text was updated successfully, but these errors were encountered:
No branches or pull requests
Traditionally, from Swift 4.2 we need
guard let selfThis is cumbersome, we can invent a higher order function to zip and unwrap the optionals
The text was updated successfully, but these errors were encountered: