Compare Protocol in Swift vs Interface in Java

后端 未结 3 413
刺人心
刺人心 2021-01-29 19:42

I\'m going through the iOS tutorial from Apple developer page.

It seems to me that protocol and interface almost have the same functionality.

3条回答
  •  一个人的身影
    2021-01-29 20:12

    Just adding one thing because I've been checking protocols combining:

    you can combine protocols at any point with the protocol<> keyword.

    This is no longer true. Based on this: https://github.com/apple/swift/blob/master/test/type/protocol_composition.swift

    This is correct:

    func foo ( var1 : A & B ){}
    

提交回复
热议问题