Swift Short Hand If...Else
Swift Short Hand If...Else
Use the ternary operator condition ? a : b for concise conditional expressions.
Basic Ternary Operator
Use the ternary operator to choose between two values in a single expression.
This example returns "Adult" when age >= 18, otherwise "Minor".
Choose the Minimum
Use a ternary expression to select the smaller of two values.
This prints the smaller number.
If a is not less than b, the expression returns b.