it's basically a confusing if else

if ($one == $two) { return 1 } else { return 0 }
-------------------------------------
------------------------------------------------
Love is everything.  It is the key to [human] life,
and its influences are those that move the world.
-- Ralph Waldo Trine




                                                                                       
                                          
                      Kevin Scaldeferri <                                              
                                          
                      <[EMAIL PROTECTED]        To:       [EMAIL PROTECTED]<           
                                            
                      eferri.com>              cc:                                     
                                          
                                               Subject:  Re: [Devel::Cover] return 
conditions                                    
                      16/09/2004 23:35                                                 
                                          
                                                                                       
                                          
                                                                                       
                                          





On Sep 16, 2004, at 2:47 PM, Tels wrote:

> -----BEGIN PGP SIGNED MESSAGE-----
>
> Moin,
>
> On Thursday 16 September 2004 23:37, Geoffrey Young wrote:
>> hi paul :)
>>
>> I think this has come up before, but I'm not sure what the resolution
>> was.
>>
>> I just came across (production) code that looks like this:
>>
>>   return 1 if $one == $two or return 0;
>
> Just FYI:
>
> I always wonder why someone would write such code.

Probably because they have some prejudice that the ternary ?: should
never be used.  (Maybe that it leads to unmaintainable code.)

Interestingly, while this snippet does what the author wanted, I'm
pretty sure how it does it is completely different than they expect.
It's actually equivalent to

if ($one == $two or return 0) {
             return 1;
}

right?


-kevin





**********************************************************************************
This email may contain confidential material. If you were not an
intended recipient, please notify the sender and delete all copies.
We may monitor email to and from our network.

Reply via email to