Swift if statement with multiple conditions

I just want some experts on Swift to confirm that the following syntaxes are equivalent:

if a > b, c > d {
}

if a > b && c > d {
}

I consulted "The Swift Programming Lanugage (version 5.7)" but the book does not cover this issue. But I believe it's true because my tests show they are the same.

Answered by myuncle in 780953022

Seems like they are: https://forums.swift.org/t/is-equal-to/31121

I prefer to use the latter and I also prefer to use parentheses when in doubt.

Accepted Answer

Seems like they are: https://forums.swift.org/t/is-equal-to/31121

I prefer to use the latter and I also prefer to use parentheses when in doubt.

Hello :)

Yes, both syntaxes are equivalent. The only difference is that if a>b, c>d is evaluated as two separate expressions and if a>b && c>d is treated as one whole expression :)

Swift if statement with multiple conditions
 
 
Q