1 min readMar 25, 2020
One question in your example
let factories = [AnyCarFactory(TeslaFactory()), AnyCarFactory(BMWFactory())]
factories.map() { $0.produce() }
If the caller already knows that the first element is TeslaFactory and second is BMWFactory why not just initialize them in the array? Why do you bother making the wrapper struct?
let factories = [TeslaFactory(), BMWFactory()]