Comparableプロトコルを作るには、
static func <(lhs: Even, rhs: Even) -> Bool
static func ==(lhs: Even, rhs: Even) -> Bool
の2つを実装すればよい。
struct M : Comparable { var val:Int static func <(lhs: M, rhs: M) -> Bool { return lhs.val < rhs.val } static func ==(lhs: M, rhs: M) -> Bool { return lhs.val == rhs.val } } let r1 = M(val:1) let p1 = M(val:2) assert(r1 < p1) let r2 = M(val:1) assert(r1 == r2)