2020-07-13 Swift3 元组比较

let score1 = (Chinese:90, math:95)
let score2 = (Chinese:90, math:100)
let score3 = (Chinese:100, math:90)

score1 < score2
score3 < score2

func <(t1:(Int,Int), t2:(Int,Int)) -> Bool {
       if t1.1 != t2.1 { // 优先比较数学成绩
            return t1.1 < t2.1
        }
        return t1.0 < t2.0
}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。