- 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.
推薦閱讀
- Mastering OpenCV Android Application Programming
- Learning Elixir
- Python數據可視化之Matplotlib與Pyecharts實戰
- Apex Design Patterns
- Python機器學習:手把手教你掌握150個精彩案例(微課視頻版)
- Learning Python by Building Games
- 用戶體驗增長:數字化·智能化·綠色化
- Nginx Lua開發實戰
- 第一行代碼 C語言(視頻講解版)
- 時空數據建模及其應用
- HoloLens與混合現實開發
- Python編程:從入門到實踐(第3版)
- iOS開發項目化入門教程
- Learning TypeScript
- Instant Pygame for Python Game Development How-to