- Learning Scala Programming
- Vikash Sharma
- 139字
- 2021-06-30 19:07:54
The do while loop
The do while loop does not differ a lot from the while loop. Generic syntax for do while loop is:
do
... // Block of Code to be executed
while(condition check (if it's true))
The do while loop ensures that the code in block gets executed at least once and then checks for the condition defined in a while expression:
scala> do println("I'll stop by myself after 1 time!") while(false)
The following is the result:
I'll stop by myself after 1 time!
It's a simple example where our statement is getting printed just once before the condition passed to the while loop is false. This is how we can use -do while loops in Scala.
You may want to try out the PagePrinter example using the while and do while loops.
推薦閱讀
- 無代碼編程:用云表搭建企業(yè)數(shù)字化管理平臺
- Visual C++數(shù)字圖像模式識別技術(shù)詳解
- 我的第一本算法書
- R語言編程指南
- Neo4j Essentials
- Java:High-Performance Apps with Java 9
- Clojure Reactive Programming
- C語言程序設(shè)計上機指導(dǎo)與習(xí)題解答(第2版)
- C和C++游戲趣味編程
- 劍指大數(shù)據(jù):企業(yè)級數(shù)據(jù)倉庫項目實戰(zhàn)(在線教育版)
- Node.js:來一打 C++ 擴展
- 量子計算機編程:從入門到實踐
- Mastering JavaScript Promises
- Improving your Penetration Testing Skills
- 軟件再工程:優(yōu)化現(xiàn)有軟件系統(tǒng)的方法與最佳實踐