In the following code in Chapter 12, can someone explain the where keyword? Is this used specifically with generic types? Is this saying "where the ResourceType conforms to Codable? So is this saying the struct parameter doesn’t care what class ResourceType is as long as it meets the minimum requirement of conforming to codable? What happens if the ResourceType doesn’t conform to Codable? Thanks in advance. Great book.
struct ResourceRequest<ResourceType>
where ResourceType: Codable {
// 2
let baseURL = "http://localhost:8080/api/"
let resourceURL: URL
// 3
init(resourcePath: String) {
guard let resourceURL = URL(string: baseURL) else {
fatalError("Failed to convert baseURL to a URL")
}
self.resourceURL =
resourceURL.appendingPathComponent(resourcePath)
}
}