kemchenj
9/26/2017 - 10:19 AM

Constructible

语法糖

import UIKit

extension UIView: Constructible { }

var views = [UIView]()

views = 5 * UILabel.self
extension Int {
    public static func *<T: Constructible>(count: Int, this: T.Type) -> [T] {
        return (0..<count).map { _ in
            return this.init()
        }
    }
}
protocol Constructible {
    init()
}