A ternary is essentially an "if/else" statement with less syntax, so we didn't really ditch the "else" statement!
Strictly speaking the conditional operator is an expression, not a statement like if…else. Given that it's an expression it has to return a value which is why the "else" expression is mandatory. So in this case "else" is a feature not a defect because it forces you to deal with either outcome explicitly — similar to exhaustiveness checking in TypeScript's discriminated unions.
Strictly speaking the conditional operator is an expression, not a statement like if…else. Given that it's an expression it has to return a value which is why the "else" expression is mandatory. So in this case "else" is a feature not a defect because it forces you to deal with either outcome explicitly — similar to exhaustiveness checking in TypeScript's discriminated unions.
if) statements (with or withoutelse) are the hallmark of Place-Oriented ProgrammingIn Value-Oriented Programming you always have to deal with "else" even if it's
undefined.