mardi 29 septembre 2020

Cleanest possible if statements (but still understandable to any)?

I want to learn to write better if statements.

Let´s say I have this code:

if someBool == true {

let someStatement = String("This is not cool")
let textCell = someTableViewCell

textCell.textlabel?.text = (" \(dateFormatter.string) \(someStatement)")

}

else {

if someBool == true {

let someStatement = String("This is cool")
let textCell = someTableViewCell

textCell.textlabel?.text = (someStatement)

}

I can imagine myself doing exactly this even with multiple lets and textcell etc. The code would be so long.

What are other, better ways to do it?

Aucun commentaire:

Enregistrer un commentaire