lundi 22 juillet 2019

Swift if statement with commas

If the if statement can take commas, what are the implications for else?

It seems to me that these two are equivalent:

 if let foo=bar, let x=y {
  // do stuff
 }
 if let foo=bar { if let x=y { /* do stuff */ }}

However the first usage does not allow for an else clause for the outer if-let, whereas the 2nd one does.

Isn't this programming practice therefore bad because it increases the chances of forgetting to handle non-happy-path cases?

Aucun commentaire:

Enregistrer un commentaire