vendredi 17 juillet 2020

Create a string that is inserted in every if statement sequence

I want to find if it’s possible to create a kind of if statement sequence that features a string in every if statement. When you look at my code below you see the string counter += 1 in every if statement. I want to find if I kind write something more efficient in like a loop to include counter += 1 in every statement.

    Var counter = 0

     If view.backgroundColor = .blue{

     counter +=1
   }

If view.backgroundColor = .red{

counter +=1
}
If view.backgroundColor = .black{

counter +=1

}

Aucun commentaire:

Enregistrer un commentaire