LoginSignup
6
6

More than 5 years have passed since last update.

Booleanは`true`と`false`のみ

Posted at

Boolean以外で条件判断しようとするとエラーになる。

let i = 1
if i {
    // this example will not compile, and will report an error
}

比較演算子を使って条件判断するとコンパイルできる。

let i = 1
if i == 1 {
    // this example will compile successfully
}

参考資料
* Booleans | The Swift Programming Language: The Basics
* The Swift Programming Language: Basic Operators

6
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
6