extend generic Array to adopt protocol

后端 未结 3 1990
生来不讨喜
生来不讨喜 2020-12-18 08:35

Let\'s say I\'ve defined such a protocol:

protocol EuclideanPoint {
    func distance(other: Self) -> Double
    func dimension() -> UInt
}
         


        
3条回答
  •  一向
    一向 (楼主)
    2020-12-18 09:20

    You can extend SequenceType instead of Array

    extension SequenceType where Generator.Element == Float {
    //
    }
    

提交回复
热议问题