Multiple Conditions for Swift 'If' Statement?

后端 未结 2 1504
一向
一向 2021-02-05 09:19

Is there a way to write an If statement is Swift such as the following?

if a>b or c/d {
    //Do Something
}
2条回答
  •  盖世英雄少女心
    2021-02-05 10:03

    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.

提交回复
热议问题