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

Popular posts from this blog

ruby on rails - RuntimeError: Circular dependency detected while autoloading constant - ActiveAdmin.register Role -

c++ - OpenMP unpredictable overhead -

javascript - Wordpress slider, not displayed 100% width -