如果条件的求值结果为FALSE或NULL,那么将绕过循环,并且控制被传递给下一条语句。
If the condition evaluates to FALSE or NULL, the loop is bypassed, and control passes to the next statement.
Python中的第二种流控制语句是while循环,它在一个表达式计算为True时执行一个程序语句块。
The second type of flow control statement in Python is the while loop, which executes a block of program statements while an expression evaluates True.
Oracle还允许将游标与一个循环语句紧密地绑定在一起,形成所谓的游标FOR循环结构。
Oracle also allows cursors to be tightly bound to a looping statement, a construct called a cursor FOR loop.
while循环(与本文后面介绍的for 循环一样)支持三种附加语句
The while loop (like the for loop introduced later in this article) supports three additional statements
我们本可以使用一个预编译语句并且每次重新设置数据,但是为了保持完整性,我们决定在每次循环的时候重新创建它。
We could have used a prepared statement and just reset the data each time, but we decided to recreate it for each iteration of the loop here for completeness.
有时,您需要一个简单的验证点,但是有时您需要条件语句,还有时您需要添加一个延迟或者循环。
Sometimes, you can get by with a simple verification point, but sometimes you need conditionals, and sometimes you need to add a delay or a loop.
在执行for语句时,游标被隐式声明,这样对于FOR循环的每一次迭代,取回的下一行就是结果集。
When a for statement is executed, a cursor is implicitly declared such that for each iteration of the for loop, the next row is the result set if fetched.
我们有一个循环,通过一个条件和一个布尔值来判断,是否触到了边缘,还有一些语句,让它回头并咆哮。
You've got a loop, you've got a condition and a Boolean to check if he's touching the edge, and some statements to tell him to shout or to actually turn around.
while语句定义了一个语句集合,如果在WHILE循环开始时某个条件的求值结果为false,那么就将执行这个语句集合。
The WHILE statement defines a set of statements to be executed until a condition that is evaluated at the beginning of the WHILE loop is false.
REPEAT语句定义了一个语句集合,如果在 REPEAT 循环结束时某个条件的求值结果为true,那么就将执行这个语句集合。
The REPEAT statement defines a set of statements to be executed until a condition that is evaluated at the end of the REPEAT loop is true.
main方法使用增强的for循环来迭代通过不同的原语,并在当前实例上使用一个简单的switch语句来设置每个原语的大小值。
The main method USES an enhanced for loop to iterate through the different primitives and a simple switch statement on the current instance to set the size value of each primitive.
如果找到一个选项,则getopts命令返回true,因此常见的选项处理范例使用带case语句的while 循环,本例中就是如此。
The getopts command returns true if an option is found, so a common option processing paradigm uses a while loop with a case statement as in this example.
如前面的文章中所述,continue语句使包含它的循环开始下一次迭代。
As discussed in the previous article, the continue statement causes the containing loop to start the next iteration.
接下来进入到循坏,这里只是简单的创建一个循环并有一个case语句用来处理到来的消息。
Next comes loop which simply creates a loop and then react which has case statements that are used to handle incoming messages.
bash中的while循环可以重复执行语句一定的次数,或者一直执行到满足某一条件为止。
A while loop within bash allows you to execute a statement a given number of times, or until a certain condition is met.
可以在循环中放一个print语句,检验在foreach循环中每个元素中是否确实存在数据。
You can place a print statement within the loop to verify that data indeed exists at each element in the foreach loop.
while循环与if语句一样,支持一个可选的else子句,其中包含一个当表达式计算为False时执行的程序语句块。
The while loop, as was the case with the if statement, supports an optional else clause containing a block of program statements executed when the expression is False.
循环体中的下一个语句是第二个if语句,它测试变量i是否能被125整除,但是该表达式前面加了一个not运算符。
The next statement in the loop body is a second if statement that tests whether the variable I is evenly divisible by 125, but this expression is preceded by the not operator.
for 循环,它对一个语句块执行一定次数。
The for loop, which executes a block of statements a certain number of times
while循环,它当一个测试表达式为true时执行一个语句块。
The while loop, which executes a block of statements as long as a test expression is true.
break语句的一个特殊特性是,它完全中断循环,并跳转到循环下面的任一个else子句。
One special feature of the break statement is that it breaks completely out of the loop, thereby skipping any else clause that follows the loop.
Scala另外一个拥有丰富特性的类似控制结构是for循环,在Scala社区中也被称为for推导语句或者for表达式。
Another familiar control structure that's particularly feature-rich in Scala is the for loop, referred to in the Scala community as a for comprehension or for expression.
continue和break语句分别用于在 while循环中继续下一次循环或中断循环。
The continue and break statements are used inside a while loop to continue with the next pass through the loop or break out of the loop, respectively.
用于递增或递减循环计数器的一条或多条表达式语句。
Expression statement or statements to increment or decrement the loop counters.
另一种常见的算法结构是当条件为“真”时,循环执行一条语句或者语句序列。
Another common algorithmic structure involves that the need to continue executing a statement or sequence of statements as long as some condition remains true.
它是公平地说,标签一个循环是唯一有用的方式,可以使用标记语句。
It is fair to say that labeling a loop is the only useful way that a labeled statement can be used.
相反的,你需要编写一个小的循环语句来反复的更新视图并按帧渲染。
Instead, you'll need to code a small loop that iteratively updates the view and renders a frame.
其他有用的经验法则:一个函数如果有判断或循环语句通常是没效率的。(除非在通常的情况下循环语句或判断语句不会执行)。
Another useful rule of thumb: it's typically not cost effective to inline functions with loops or switch statements (unless, in the common case, the loop or switch statement is never executed).
最有可能的原因是您的程序陷入了一个含有输出语句的死循环中。
The most common cause is that your programs falls into an infinite loop containing some output operations.
循环语句将在下一章作具体讲解。
应用推荐