How to convert if/else to ternary if/else?
if(con){
if(con2){
result1
}else{
result2
}
}
i tried , but i get miss.. :
con?con2?result1:result2;
How to convert if/else to ternary if/else?
if(con){
if(con2){
result1
}else{
result2
}
}
i tried , but i get miss.. :
con?con2?result1:result2;
con ? (con2 ? result1 : result2) : null;
con && (con2 ? result1 : result2)
You can use && if you don't have an else branch. But why would you replace a beautiful if statement with such unreadable shortforms?