【发布时间】:2012-11-03 17:18:38
【问题描述】:
我想从try 块内退出:
function myfunc
{
try {
# Some things
if(condition) { 'I want to go to the end of the function' }
# Some other things
}
catch {
'Whoop!'
}
# Other statements here
return $whatever
}
我用break 进行了测试,但这不起作用。如果任何调用代码在循环内,它会中断上层循环。
【问题讨论】:
-
我相信只有 VB.net 有“退出尝试”。虽然下面的脚本块技巧相当聪明!
标签: powershell try-catch