I wanted an if-else
clause to behave based on an input that would leave the statements as is, or switch statements between if and else.
To be specific, I am parsing an html tag country
and uncountry
. Based on its attribute, which lists the countries for the tag, I will be able to decide whether to skip the inner content or not. country
tag will copy inner content, while uncountry
does the opposite. The if (parseCountry)
is to parse country
tag, and the else for uncountry
tag.
For example:
if (parseCountry)
{
if (inCountryList)
{
do A;
do B;
}
else if (notInCountryList)
do C;
}
else
{
if (inCountryList)
do C;
else if (notInCountryList)
{
do A;
do B;
}
}
What is the best way to simplify the if-else statements above? Thanks.