官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 达孜县| 通化市| 兴宁市| 江口县| 年辖:市辖区| 刚察县| 阳信县| 永寿县| 鄂州市| 广平县| 化州市| 山西省| 六枝特区| 宜兴市| 蓝田县| 嫩江县| 文山县| 共和县| 桃园县| 锡林郭勒盟| 武汉市| 上思县| 广西| 玉门市| 大理市| 韶山市| 防城港市| 益阳市| 宁都县| 明溪县| 崇仁县| 古交市| 庄浪县| 万盛区| 三明市| 尖扎县| 鹤峰县| 湟中县| 丰顺县| 鄂托克前旗| 淮南市|