In most language a short form of if else is available. It is a space saver as well as helps maintain clean code. The form is
if (condition=true) then return 1 else return 0. It can be written in different languages as follows
Paid = IsTheBillPaid(id) ? 1 : 0;
The actual condition here after the equal sign. The fist statement can be a function or logical test. The function must return a logical true or false value in order to work here. If the value is true the value after question mark (?) mark is returned. Otherwise the value after colon (:).
if (number1 > number2>
result = “greater”;
In short hand form, it becomes
result = number1 > number2 ? “greater” : “smaller”;
As you can see the code with shorthand form is much cleaner and clear. This was brief demonstration of “if else short form”.