Break语句

块可以用一个 break 语句跳出。break语句可以跳出一个 while, for, 或 block 语句. 它跳出最内层的结构, 除非给定一个块标签:

  1. block myblock:
  2. echo "entering block"
  3. while true:
  4. echo "looping"
  5. break # 跳出循环,但不跳出块
  6. echo "still in block"
  7.  
  8. block myblock2:
  9. echo "entering block"
  10. while true:
  11. echo "looping"
  12. break myblock2 # 跳出块 (和循环)
  13. echo "still in block"