I use Swift 3 and I want to init a String let variable based on a boolean. I know how to do it with a standard if statement with a var variable but not as a one line expression.
With Java i would do:
String str = myBool ? "John" : "Peter";
Is there a equivalent with Swift 3 to not use a var and in a one-line way?
Aucun commentaire:
Enregistrer un commentaire