jeudi 1 décembre 2016

Swift: "Where" vs "If"

Is there any difference between these two syntaxes? If not, any benefit?

if let userName = userNameTextField.text where userName.characters.count > 0,
        let password = passwordTextField.text where password.characters.count > 0,
        let confirmation = confirmationTextField.text where confirmation == password
    else {
        return false
    }

and:

if userNameTextField.text?.characters.count > 0 &&
        passwordTextField.text?.characters.count > 0 &&
    confirmationTextField.text == passwordTextField.text
    {
        return false
    }

Aucun commentaire:

Enregistrer un commentaire