Chinaunix

标题: 求教:跳出2层循环的方法 [打印本页]

作者: liuzeng001    时间: 2011-08-25 08:44
标题: 求教:跳出2层循环的方法
前提,使用Bshell

我在使用while文中,用break只能跳出一层循环。
有没有方法象C语言的goto那样跳出多层循环的方法?

求高手赐教。
作者: waker    时间: 2011-08-25 08:54
break n
作者: liuzeng001    时间: 2011-08-25 09:00
太感谢了,果然是高手啊。
终于在循环里逃出来了,谢谢。
今后还请多指教啊。
作者: luyi1983    时间: 2011-08-25 09:05
回复 3# liuzeng001

ABS 居家旅行之必备良药。。。
    The break command may optionally take a parameter. A plain break terminates only the innermost
loop in which it is embedded, but a break N breaks out of N levels of loop.




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2