2

I have a Result, success don't have value.

typealias MyResult = Result<Void, Error>

Use

let myResult: MyResult = .success(())

Is it possible like this?

let myResult: MyResult = .success()

I try to change define MyResult, but not correctly :(

typealias MyResult = Result<_, Error>   //Expected type
typealias MyResult = Result<nil, Error> //Expected type

Is there any other way to define this Result?

aiur
  • 649
  • 2
  • 7
  • 21

1 Answers1

-2

Use Error? as your result type.

typealias MyResult = Error?

extension MyResult {

    var isSucceeded: Bool { return self == .none } 
}
  • The question is about the [Result](https://developer.apple.com/documentation/swift/result) type of Swift 5 – vadian May 22 '19 at 12:04