Break语句
块可以用一个 break 语句跳出。break语句可以跳出一个 while, for, 或 block 语句. 它跳出最内层的结构, 除非给定一个块标签:
- block myblock:
- echo "entering block"
- while true:
- echo "looping"
- break # 跳出循环,但不跳出块
- echo "still in block"
- block myblock2:
- echo "entering block"
- while true:
- echo "looping"
- break myblock2 # 跳出块 (和循环)
- echo "still in block"