美文网首页
2020-07-13 Swift3 元组比较

2020-07-13 Swift3 元组比较

作者: 程序员都是傻子呀 | 来源:发表于2020-07-13 17:21 被阅读0次
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
}

相关文章

网友评论

      本文标题:2020-07-13 Swift3 元组比较

      本文链接:https://www.haomeiwen.com/subject/wchzcktx.html