- Learning Scala Programming
- Vikash Sharma
- 97字
- 2021-06-30 19:07:49
Boolean literals
These are simple, they indicate 0 or 1, which mean true or false. The basic use of Boolean literals is for operating on comparisons, or conditions. These two are called Boolean literal, which can't be replaced by 0 or 1:
scala> val aBool: Boolean = 1
<console>:11: error: type mismatch;
found : Int(1)
required: Boolean
val aBool: Boolean = 1
^
To define a Boolean value, we simply give true or false:
scala> val aBool = true
aBool: Boolean = true
scala> val aBool = false
aBool: Boolean = false
That's all for Boolean literals.
推薦閱讀
- Learning Elixir
- Java加密與解密的藝術
- C語言程序設計案例式教程
- Mastering macOS Programming
- Java EE 8 Application Development
- 組態軟件技術與應用
- 大數據分析與應用實戰:統計機器學習之數據導向編程
- C語言程序設計實驗指導 (第2版)
- Kotlin編程實戰:創建優雅、富于表現力和高性能的JVM與Android應用程序
- OpenCV 4計算機視覺項目實戰(原書第2版)
- Python Data Structures and Algorithms
- Mastering Akka
- 現代C++編程實戰:132個核心技巧示例(原書第2版)
- Python函數式編程(第2版)
- RocketMQ實戰與原理解析