使用VBScript编程过程中我写了很多的功能的误差校验码功能开始前做动作。所以,如果一些预reqierements wan't满足,那么我愿意“退出功能”。因此,例如:功能的多个出口点:这是一个好办法吗?
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
请分享你的看法。