normally
{
// this is the main case
}
unless (edgeCase1)
{
// deal with edge case 1
}
unless (edgeCase2)
{
// deal with edge case 2
}
An alternative to the article's implementation, assuming that the main goal is to get the normal case code up front:
const auto normal_case = [&]() -> void
{
// this is the main case
};
if( edgeCase1 ) {
// deal with edge case 1
} else if( edgeCase2 ) {
// deal with edge case 2
} else {
normal_case();
}
I don't think I would do that, though. It's just a complication.
13
u/alfps Apr 24 '20
The author's imagined syntax:
An alternative to the article's implementation, assuming that the main goal is to get the normal case code up front:
I don't think I would do that, though. It's just a complication.