There are many discussions related to whether it is better to have only one or multiple exit points per function, but it is not clear to me which statements can be considered as exit points: only return
or some other ones as well?
For example, should we consider throw
and break
as exit points?
Are there 2 or 3 exit points?
func(x, y) {
// guard
if (!x)
throw "You have an error here!"
if (y)
return "foo"
else
return "bar"
}
Are there 1 or zero exit points?
func() {
i = 1
loop {
if (i == 5)
break
show_message(i)
i = i + 1
}
}