in reply to Re^2: Conditional Operator Confusion
in thread Conditional Operator Confusion
The trinary is much like any other operator, for example ==. Lets try this example,
my $result = $a == $b
Here, you get the result of the == operator, is $a equal $b. If they match it returns true, if they don't match it returns false.
The trinary works in a similar manner except you are setting the value returned instead of the implied value of other operators.
my $result = $a == $b ? 1 : 0;
This does the same thing as the first example, except you are explicitly setting the value returned. Does this help?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^4: Conditional Operator Confusion
by Melly (Chaplain) on Nov 30, 2006 at 17:03 UTC | |
by ikegami (Patriarch) on Nov 30, 2006 at 17:12 UTC | |
by Melly (Chaplain) on Nov 30, 2006 at 17:25 UTC |