How to return the value if I doesn't need hit block2.
Does it make sense or not? I think I shouldn't use multi return
, but I can't replace it with break
. there is No enclosing loop out of which to break or continue.
public EnResult MyFun()
{
bool bRet = default;
// block1 . higher priority than block2.
if (true)
{
// if bRet = true_1, not need hit block2. That's why I want to nested my code with multi *return*
return bRet = true_1;
}
else
{
// do nothing
}
// block2
if (true)
{
return bRet = true_2;
}
else
{
// do nothing
}
return bRet;
}
public enum EnResult
{
true_1,
true_2,
false_1,
false_2,
default,
}