in reply to Re^2: Short form (ternary) if else
in thread Short form (ternary) if else
Yes and no... It is typically at it's most useful after an assignment, and it's use is that it generates a value, but that doesn't necessarily mean it needs to be used in an assignment. Others have given examples, but the essential thing to remember is that the ternary operator returns a value. if does not: It is a flow-control operator.
So, where it does need to be used is where Perl would expect a value. Assignments are one common case of that.
|
---|