I want to unwrap two optionals in one if statement, but the compiler complaints about an expected expression after operator at the password constant. What could be the reaso
Based on @Joel's answer, I've created a helper method.
func unwrap(a:T?, b:U?, handler:((T, U) -> ())?) -> Bool { switch (a, b) { case let (.Some(a), .Some(b)): if handler != nil { handler!(a, b) } return true default: return false } }
// Usage
unwrap(a, b) { println("\($0), \($1)") }