全部版块 我的主页
论坛 计量经济学与统计论坛 五区 计量经济学与统计软件 Stata专版
2208 1
2016-05-11
悬赏 2 个论坛币 未解决
请问,嵌套foreach循环语句里面,用continue, break命令是跳出本层循环还是终止全部循环?如果是终止全部循环的话,怎么做才能只终止本层次的循环,而继续更高级的循环?
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

全部回复
2016-5-17 01:07:19
The continue command within a foreach, forvalues, or while loop breaks execution of the
    current loop iteration and skips the remaining commands within the loop.  Execution resumes
    at the top of the loop unless the break option is specified, in which case execution
    resumes with the command following the looping command.
帮助文件里已经说清楚了的help continue

自己验证一下也很容易
foreach a in 1 2 3 {
foreach b in 4 5 6 {
if `b'==5 {
continue, break
}
noi di "`a' `b'"
}
}
输出

1 4
2 4
3 4
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群