次のようなコードがあります。
if(condition1)
{
//do some stuff
if(condition2)
{
//do some other stuff
if(condition3)
{
//do some more stuff
if(condition4)
{
//you probably got the point by now...
}
}
}
そして、見栄えが良く、従いやすいコードにリファクタリングしたいと思います。
これまでのところ、私が得た最高のものは次のとおりです。
do{
if(!condition1){break;}
//do some stuff
if(!condition2){break;}
//do some other stuff
if(!condition3){break;}
//do some more stuff
if(!condition4){break;}
//you probably got the point by now...
}while(false);
私の質問は次のとおりです:
私が見逃している別のより良い方法はありますか?
関連性はないと思いますが、私はC#を使用しています...