and data types without being specific about the types they use ▸ Generic code enables you to write flexible, reusable functions and types that can work with any type, subject to requirements that you define
powerful features of Swift ▸ Much of the Swift standard library is built with generic code ▸ You’ve already been using generics, even if you didn’t realise it
90 } public func ?=<T>(inout left: T, right: T?) { guard let value = right else { return } left = value } public func ?=<T>(inout left: T?, right: T?) { guard let value = right else { return } left = value } // ... func testIfLetAssignment() { let hyper = NSURL(string: "hyper.no")! let faultyURL = NSURL(string: "\\/http") var testURL: NSURL? testURL ?= hyper // "hyper.no" testURL ?= faultyURL // "hyper.no" }