··· class C { required init() {}
func f() { print("Hello from C") }
}
extension Array where Element: C { init(num: Int) { self.init() for _ in 0..<num { self.append(Element()) } }
func callFOnEverything() { for obj in self { obj.f() } }
}
Array
···
原文链接:https://www.f2er.com/swift/325138.html