在使用 VBScript 编程期间,我在函数开始执行操作之前在函数中编写了很多错误检查代码。因此,如果某些预先要求不满足,那么我会执行“退出功能”。因此,例如:
public fucnton func
if not condition then
func = -1
exit function
End If
'Other conditions with exit functions
'Then long code goes here
..........
..........
..........
func = res
End Function
所以,我可以从多个点退出函数。这是好方法吗?在这种情况下,我会得到 if 语句的长 else 分支
也许最好写:
public fucnton func
if not condition then
func = -1
Else
'Then long code goes here
..........
..........
..........
End If
End Function
请分享你的想法。