I often have to do something like this,
if(condition1) {
if {condition2) {
}
else{
}
}
else {
if {condition2) {
}
else{
}
}
In principle, only checking that (condition2) is repeated in both cases, and dosomething is different in all 4 places, i.e. code1, code2, code3, code4 are all different codes.
So, is there a way to make it compact and readable? Or is this normal?
Thank.
After going through editing and looking at the answers, I wonder if this question really makes sense. Now I feel stupid.
source
share