Lawrence Statton wrote:
>
> On Mar 29, 2010, at 10:54 AM, r...@i.frys.com wrote:
>>
>> I looked through perlop and was unable to find where it
>> stated that the ternary operator should only be used in
>> an
>> assignment such as you've shown.  Can you point out
>> where
>> that's located.
>>
>
> In my reasonably-arrogant opinion:  That's kind of
> embedded in the
> DEFINITION of the word "operator"
>
Just because it's an operator, doesn't mean that it must
and only be used in an assignment.

By your/the DEFINITION of the word "operator", then the ..
range operator must also only be used in an assignment,
which we know is not true.
>
>
>> I often use the ternary operator when working with
>> dispatch tables.  Based on your comment, I suspect that
>> you feel that the following example is a poor use of the
>> ternary operator.  Please correct me if I'm wrong.
>>
>> exists $dispatch{$status} ? $dispatch{$status}->()
>>                          : $dispatch{'error'}->();
>>
>
> I would definitely avoid that construction and find a
> better idiom ...
> but you don't work for me, so you can feel free to ignore
> my advice.
>
I have no problem following advice, provided there is good
reason.  So far, you have not provided any reason why I
should change my approach, nor have you shown a better
approach.


-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to