Uri Guttman wrote:
>>>>>> "r" == rkb  <r...@i.frys.com> writes:
[snip]

>   r> I often use the ternary operator when working with
>   r> dispatch tables.  Based on your comment, I suspect
> that
>   r> you feel that the following example is a poor use of
> the
>   r> ternary operator.  Please correct me if I'm wrong.
>
>   r> exists $dispatch{$status} ? $dispatch{$status}->()
>   r>                           : $dispatch{'error'}->();
>
> you don't need exists on a dispatch table. and i code them
> like this:
>
>       my $code = $dispatch{$status} || $dispatch{'error'} ;
>       $code->() ;
>
> very clean, no duplication of $dispatch{$status} or the
> code call, easy
> to see the error case.
>
> uri

Yes, that does look like a better approach.

Thanks

Ron Bergin


-- 
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