- 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.
推薦閱讀
- Raspberry Pi for Python Programmers Cookbook(Second Edition)
- C# 2012程序設計實踐教程 (清華電腦學堂)
- 編程卓越之道(卷3):軟件工程化
- OpenCV 3和Qt5計算機視覺應用開發
- 微信小程序項目開發實戰
- Python項目實戰從入門到精通
- Extreme C
- LabVIEW虛擬儀器程序設計從入門到精通(第二版)
- Hands-On Nuxt.js Web Development
- 單片機原理及應用技術
- 現代C:概念剖析和編程實踐
- Advanced Python Programming
- INSTANT Apache Hive Essentials How-to
- Android嵌入式系統程序開發(基于Cortex-A8)
- Kotlin語言實例精解