Using Stride in Swift 2.0

好久不见. 提交于 2019-12-02 21:58:06

It changed a bit, here is the new syntax:

0.stride(to: 10, by: 2)

and

Array(0.stride(to: 10, by: 2)) // is [0, 2, 4, 6, 8]

if you take a look at here, you can see what types conform to the Strideable protocol.

As @RichFox pointed out, in Swift 3.0 the syntax changed back to the original global function form like:

stride(from:0, to: 10, by: 2)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!