swift3.0 for循环

前端之家收集整理的这篇文章主要介绍了swift3.0 for循环前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
let numberList = [11,12,13,14,15,16]
        
        for item in numberList{
            print(item)
        }
        
        for item in numberList.enumerated(){
            print(item.offset,item.element)
        }
        
        for (index,item) in numberList.enumerated().reversed() {
            print(index,item)
        }
        
        for i in 0..<5 {
            print("--",numberList[i])
        }
        
        for i in 0...5{
             print("==",i)
        }
        
        for i in (0...5).filter({ i in i % 2 == 1}) {
            print("***",i)
        }
        
        for i in (0...5).filter({ $0 > 2}) {
            print("###",i)
        }

赠送一种数组截取方式

array(groups![startIndex...endIndex])
原文链接:https://www.f2er.com/swift/322638.html

猜你在找的Swift相关文章