Avatar
norio_nomura 8/1/2018 11:36 AM
Making a claim that something will never be the case can feel like an invitation for the universe to prove otherwise. Fortunately for us, Swift lives up to this higher standard thanks to the unlikeliest of types.
11:37 AM
Result<String, Never>だとswitchcase . failure書かなくても良いのか。 @swift-main import Foundation enum Result<Value, Error: Swift.Error> { case success(Value) case failure(Error) } func alwaysSucceeds(_ completion: (Result<String, Never>) -> Void) { completion(.success("yes!")) } alwaysSucceeds { (result) in switch result { case .success(let string): print(string) } }
👀 2