4.4. Combining operators
Swift has two operators that let us combine multiple conditions. They are && (and), and || (or).
Let's look into an example:
let myAge = 24
if myAge >= 18 && myAge <= 65 {
print("Eligible for the user study!")
}
if myAge < 18 || myAge > 65 {
print("Not eligible!")
}It means if myAge is more than or equal to 18 and less than or equal to 65, print "Eligible for the user study!"; if myAge is less than 18 or greater than 65, print "Not eligible!"
Last updated
Was this helpful?