Swift Equatable Protocol

前端 未结 3 1063
南方客
南方客 2020-11-29 06:24

I was folling this tutorial for Swift: https://www.raywenderlich.com/125311/make-game-like-candy-crush-spritekit-swift-part-1 and came across this code:

func          


        
3条回答
  •  萌比男神i
    2020-11-29 06:43

    Move this function

    func == (lhs: Cookie, rhs: Cookie) -> Bool {
        return lhs.column == rhs.column && lhs.row == rhs.row
    }
    

    Outside of the cookie class. It makes sense this way since it's overriding the == operator at the global scope when it is used on two Cookies.

提交回复
热议问题