expression is an object of a type that represents a sequence
declaration defines the variable that we’ll use to access the underlying elements in the sequence
On each iteration, the variable in declaration is initialized from the value of the next element in expression. means not the element itself, but a new variable have the value of the element.
Example
==easy to use auto:==
for(auto c : str)
to Change the Elements in Sequence?
use reference, because reference is actually the element:
for(auto &c : str)
The do while Statement
⚠️ 就算保底会运行一次,但是还是遵循着 “cond用不了state中的init”
Jump Statements
The break Statement
The continue Statement
while and do while will continue to evaluate the condition.
traditional for will continue at the expr. (这里我实验,发现是expr之后再cond,其实不冲突,实际上就是去expr,然后进入下一个iterate,而进入下一个iterates的第一步就是cond)
range for will continue by init the control variable from the next element