[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Omaha.pm] short is good



Maybe it's my old brain, but I like using "return" in this context for code that isn't being submitted to a PerlGolf competition.

I've encountered enough bad/sketchy coding that didn't define a return value for a subroutine that I would be suspicious if the original programmer /meant/ to return the $self->send() value, or if they thought they were calling some other routine (and the return value was just a by-product/accident).

Golf is great, but it isn't always productive.  (Much like "real golf".)

DanL

2010/4/21 Theodore Katseres <tedkat@gmail.com>
2010/4/20 Jay Hannah <jhannah@omnihotels.com>

laugh... caught myself changing code to this

 

   my $response;

   unless ( $response = $self->send() ) {

     return 0;

   }

   return $response;

 

this is much better:

 

   return $self->send();


For some extra GOLF points you could

{
 ...
  $self->send();
}
 
--
Ted Katseres
     ||=O=||

_______________________________________________
Omaha-pm mailing list
Omaha-pm@pm.org
http://mail.pm.org/mailman/listinfo/omaha-pm



--
***************** ************* *********** ******* ***** *** **
"Quis custodiet ipsos custodes?"
   (Who can watch the watchmen?)
   -- from the Satires of Juvenal
"I do not fear computers, I fear the lack of them."
   -- Isaac Asimov (Author)
** *** ***** ******* *********** ************* *****************