I'm a beginner with Swift and had a quick question about the structure of "if" and "else". I am following a tutorial about validating usernames and passwords.
This is the current code I have:
let username = "brian0306"
let password = "secret"
if (username == "brian0306") {
println("đ")
if (password == "secret") {
println("❤️")
} else {
println("Uh oh, your credentials are wrong!")
}
} else {
println("Uh oh, your username is wrong!")
}
Why is the tutorial suggesting that I place the password validation code within the username validation function?
Is it more effective if I validate the username and password in separate functions?
Brian
Aucun commentaire:
Enregistrer un commentaire