- Hands-On Design Patterns with Kotlin
- Alexey Soshin
- 24字
- 2021-06-25 20:49:26
While loop
There are no changes to the while loop functionality, so we'll cover them very briefly:
var x = 0
while (x < 10) {
x++
println(x)
}
This will print numbers from 1 to 10. Note that we are forced to define x as var. In the following chapters, we'll discuss much more idiomatic ways to do this.
The lesser used do while loop is also present in the language:
var x = 5
do {
println(x)
x--
} while (x > 0)
推薦閱讀
- 計算機網絡
- JavaScript百煉成仙
- LaTeX Cookbook
- INSTANT OpenCV Starter
- Manga Studio Ex 5 Cookbook
- JavaScript+jQuery開發實戰
- UI智能化與前端智能化:工程技術、實現方法與編程思想
- Learning Neo4j 3.x(Second Edition)
- 游戲程序設計教程
- Instant RubyMotion App Development
- Learning R for Geospatial Analysis
- Building Machine Learning Systems with Python(Second Edition)
- 大話Java:程序設計從入門到精通
- Python+Office:輕松實現Python辦公自動化
- 官方 Scratch 3.0 編程趣味卡:讓孩子們愛上編程(全彩)