🔸Result

Swift 5.0, Xcode 10.2 新功能。

定義

Swift’s Result type is implemented as an enum that has two cases: success and failure.

/// represents either a success or a failure, including an
/// associated value in each case.
@frozen
public enum Result<Success, Failure: Error> {

  /// A success, storing a `Success` value.
  case success(Success)

  /// A failure, storing a `Failure` value.
  case failure(Failure)
}

Last updated