I wonder if possible to write ternary operator for single return. I tried google online, but couldn't find an answer. or it doesnot called ternary operator??
Thank you very much for your advice.
If(A == 1) execute_function(); into A == 1 ? execute_function() //???Possible???
yes:
(exists == 1) ? execute_function() : false;
runs function if exists is true else wont
Added: Doing just like following would be better:
if( A == 1 ) {
execute_function();
}
As using ternary operator in above case is not so fruitful, as you are checking only for the true side of the condition and do not care about what's in the false side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With