December 2018
Intermediate to advanced
414 pages
10h 19m
English
Now that we have all of the components required to implement our public wrapper, let's have a look at what's left to do:
final class AnyAnimal<T>: Animal where T: Food { typealias FoodType = T private let box: _AnyAnimalBase<T> init<A: Animal>(_ animal: A) where A.FoodType == T { box = _AnyAnimalBox(animal) } // Call forwarding for implementing Animal var preferredFood: T? { get { return box.preferredFood } set { box.preferredFood = newValue } } var name: String { return box.name ...Read now
Unlock full access