在查看由其他员工处理的一些代码时,我看到很多代码是这样写的:
do{
...
}while(false);
这有什么好处(如果有的话)?
这是代码中发生的更多骨架:
try{
do{
// Set some variables
for(...) {
if(...) break;
// Do some more stuff
if(...) break;
// Do some more stuff
}
}while(false);
}catch(Exception e) {
// Exception handling
}
更新:
C++ 版本:
do-while-false 循环是否常见?