Skip to content

Latest commit

 

History

History
17 lines (10 loc) · 768 Bytes

5.15.do-while.md

File metadata and controls

17 lines (10 loc) · 768 Bytes

5.15.do-while

do-while 循环由 do 关键字开始,后跟循环体表达式。其后跟while 关键字,然后是一个 开口的圆括号 (,再跟条件表达式和一个闭口的圆括号 ) :

A do-while loop starts with the do keyword followed by the loop body expression. After that follows the while keyword, an opening parenthesis (, the condition expression and a closing parenthesis ):

do expression while(condition); 

条件表达式必须为Bool类型。

The condition expression has to be of type Bool.

如语法所暗示的,循环体表达式至少会执行一次,这和 while循环(第5.14节)不同。

As the syntax suggests, the loop body expression is always evaluated at least once, unlike while (5.14) loops.