Is there a way to write an If statement is Swift such as the following?
if a>b or c/d {
//Do Something
}
Just like everywhere:
if a > b || d % c == 0 {
// do sth
}
I assume your c/d
means you'd like d
to be a multiple of c
.
Swift uses the same operators as all C-based languages, so
if a > b || c < d {
}
where ||
is the OR operator, &&
is the AND operator.
The list of all operators can be found in Swift Basic Operators
Not sure what c/d
condition is supposed to mean.
for and operation we can use
if x==y && y == z { //perform some operations }
for or operation we can use
if x==y || y == z { //perform some operations }
if number == (1, 2, 3)
or maybe ranges of numbers ?if number == 1..3