This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example of refactoring with protocols | |
// Original javascript version is from Refactoring (2nd Edition) by Martin Fowler | |
import Foundation | |
struct Play { | |
enum Genre { | |
case tragedy | |
case comedy | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public enum NetworkingError: Error { | |
case unknown | |
case unexpectedStatus(HTTPURLResponse) | |
} | |
extension URLSession { | |
func load(_ url: URL, | |
completionHandler: @escaping (Result<Data, Error>) -> Void) | |
-> URLSessionDataTask { | |
let task = dataTask(with: url) { data, response, error in |
OlderNewer