sequence - Using Stride in Swift 2.0 -
i'm trying figure out how use stride features in swift.
it seems have changed again, since xcode 7.0 beta 6.
previously use
let strideamount = stride(from: 0, to: items.count, by: splitsize) let sets = strideamount.map({ clients[$0..<advance($0, splitsize, items.count)] })
now, despite code hint cannot figure out how use feature.
any examples helpful thanks.
i've looked @ examples, cannot come grips how use it. apple docs limited.
thanks
it changed bit, here new syntax:
0.stride(to: 10, by: 2)
and
array(0.stride(to: 10, by: 2)) // [0, 2, 4, 6, 8]
if take @ here, can see types conform strideable
protocol.
as @richfox pointed out, in swift 3.0 syntax changed original global function form like:
stride(from:0, to: 10, by: 2)
Comments
Post a Comment