Mute returns from functions - should we avoid them?
Posted: 15 Sep 2019, 16:24
Are there any reasons to have functions like this one?
In real life, it can has a lot of code. The key point is that it has only one exit point, and this exit point is mute.
Here are another examples, to compare them with the first one:
So, my question could be asked in another way:
Is it correct that we should avoid to use mute Returns when returning from functions, and use Return False, Return "Error" or something similar instead?
Code: Select all
Func(Var)
{
If (Var = "Foo")
Return
}
Here are another examples, to compare them with the first one:
Code: Select all
Func(Var)
{
If (Var = "Foo")
Return False
}
Code: Select all
Func(Var)
{
If (Var = "Foo")
Return "Error"
}
Is it correct that we should avoid to use mute Returns when returning from functions, and use Return False, Return "Error" or something similar instead?