Slide 28
Slide 28 text
type transparency
struct Photo: Codable {
var title: Refined>>
var height: Refined>
var width: Refined>
}
let jsonString = "{\"width\":150,\"height\":150,\"title\":\"Apple\"}"
let jsonData = jsonString.data(using: .utf8)!
let photo = try! JSONDecoder().decode(Photo.self, from: jsonData)
_ = photo.width * 2.0
_ = "photo called " + photo.title
XCTAssertEqual(photo.title, "Apple")
XCTAssertEqual(photo.width, 150)
github.com/hectr