- Android Development with Kotlin
- Marcin Moskala Igor Wojda
- 118字
- 2021-07-02 18:48:36
The Boolean type
Boolean is a logic type that has two possible values: true and false. We can also use the nullable Boolean type:
val isGrowing: Boolean = true val isGrowing: Boolean? = null
The Boolean type also supports standard built-in operations that are generally available in most modern programming languages:
- ||: Logical OR. Returns true when any of two predicates return true.
- &&: Logical AND. Returns true when both predicates return true.
- !: Negation operator. Returns true for false, and false for true.
Keep in mind that we can only use a not-null Boolean for any type of condition.
Like in Java, in || and && predicates are evaluated lazily, and only when needed (lazy conjunction).
推薦閱讀
- 計(jì)算機(jī)網(wǎng)絡(luò)
- UML+OOPC嵌入式C語言開發(fā)精講
- Groovy for Domain:specific Languages(Second Edition)
- 小程序,巧運(yùn)營(yíng):微信小程序運(yùn)營(yíng)招式大全
- SQL基礎(chǔ)教程(視頻教學(xué)版)
- D3.js 4.x Data Visualization(Third Edition)
- INSTANT Passbook App Development for iOS How-to
- Java Web開發(fā)就該這樣學(xué)
- Swift 4從零到精通iOS開發(fā)
- Python大規(guī)模機(jī)器學(xué)習(xí)
- Implementing Microsoft Dynamics NAV(Third Edition)
- Drupal 8 Development Cookbook(Second Edition)
- After Effects CC技術(shù)大全
- Qt 5.12實(shí)戰(zhàn)
- C++面向?qū)ο蟪绦蛟O(shè)計(jì)