美文网首页
Swift 3 新特性 1.

Swift 3 新特性 1.

作者: Maserati丶 | 来源:发表于2018-11-08 00:06 被阅读0次

课程来自慕课网liuyubobobo老师


来自Swift2.2的更新

  1. 弃用++和--
    a += 1 
    
  2. 弃用C风格的for循环
    • 倒序
    for i in (1..<10).reversed(){
    
    }
    
    • 步长不为1
    for i in stride(from:0, to:10, by:2){
        // to 为开区间 through 为闭区间  by为步长
    }
    
  3. 元组的变化:元组可以进行比较
    let score1 = (chinese:90,math:90)
    let score2 = (chinese:90,math:95)
    
    score1 < score2  // true
    
  4. (#selector:)更方便编译器查错

相关文章

网友评论

      本文标题:Swift 3 新特性 1.

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