Extending typed Arrays (of primitive types like Bool) in Swift 3?

后端 未结 4 2091
别那么骄傲
别那么骄傲 2021-02-07 20:57

Previously in Swift 2.2 I\'m able to do:

extension _ArrayType where Generator.Element == Bool{
    var allTrue : Bool{
        return !self.contains(false)
    }         


        
4条回答
  •  失恋的感觉
    2021-02-07 21:23

    Extending _ArrayProtocol or Collection didn't work for me but Sequence did.

    public extension Sequence where Iterator.Element == String
    {
        var allTrue: Bool { return !contains(false)
    }
    

提交回复
热议问题