如何重构嵌套的if语句

时间:2015-03-19 21:04:23

标签: if-statement nested

if (a or b)
  if (a)
     //do something
  else
     //do something
else
   //do something

如何重构上面的嵌套if?

1 个答案:

答案 0 :(得分:1)

if (a) {
  //do something
} else if (b) {
  //do something
} else {
  //do something
}