Notes: Swift Result
Definition 1 2 3 4 5 6 7 8 9 10 /// A value that represents either a success or a failure, including an /// associated value in each case. @frozen public enum Result<Success, Failure> where Failure : Error { /// A success, storing a `Success` value. case success(Success) /// A failure, storing a `Failure` value. case failure(Failure) } Example 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 struct Person: Decodable { let name: String let age: Int } extension String: Error {} func loadPerson(from json: String) -> Result<Person, Error> { guard let data = json.