Can I use 'where' inside a for-loop in swift? -
is there possibility use 'where' keyword in place switch? can use in in loop example?
i have array bools, value, can this:
var boolarray: [bool] = [] //(...) set values , stuff value value == true in boolarray { dosomething() }
this lot nicer use if, wondering if there possibility use in combination for-loop. ty time.
in swift 2, new where
syntax added:
for value in boolarray value == true { ... }
in pre 2.0 1 solution call .filter
on array before iterate it:
for value in boolarray.filter({ $0 == true }) { dosomething() }
Comments
Post a Comment