我有一個缺兵少將有點麻煩嵌套速記if語句我想不出如果
($product == "vindo") ? $this->getNextVindoInList($id) : $this->getNextGandrupInList($id),
這工作得很好,但我想在這句話的另一個檢查。像這樣:
if($product == "vindo") {
if($number != 14) {
$this->getNextVindoInList($id)
}
} else {
if($number != 22) {
$this->getNextGandrupInList($id)
}
}
要小心,太多的使用會導致更難閱讀代碼!它的性能收益也很小,不會更快也可能更慢。 – Brian
請不要。簡碼不是更好的代碼。 – Sulthan