Swift Struct doesn't conform to protocol Equatable?

前端 未结 4 2032
轻奢々
轻奢々 2021-02-07 01:37

How do I make a structure conform to protocol \"Equatable\"?

I\'m using Xcode 7.3.1

struct MyStruct {
   var id: Int
   var value: String

   init(id: In         


        
4条回答
  •  盖世英雄少女心
    2021-02-07 02:19

    Class and struct are different. Struct is value type, but class is reference type.

    You cannot define struct in class. On the contrary, you cannot define class in struct.

    Struct and class both can conform to any protocol including your custom protocol.

提交回复
热议问题