Re: Multiple return statements in a function.

From: Date: Thu, 23 Apr 2009 15:21:33 +0000
Subject: Re: Multiple return statements in a function.
References: 1 2 3 4  Groups: php.general 
Request: Send a blank email to php-general+get-291876@lists.php.net to get a copy of this message
On Thu, Apr 23, 2009 at 10:14:28AM -0400, tedd wrote: > At 2:19 PM +0100 4/23/09, Tony Marston wrote: <snip> >> There is no such "rule", it is a matter of personal preference. As a >> previous poster has already said, if you want to leave a function early >> and >> ignore all subsequent processing it is easier to understand if you return >> immediately rather than have a mechanism to jump over the remaining code >> to >> a single return point. In the good old days we used to use the GOTO in >> COBOL >> to jump to the exit point, but then people found a way to abuse GOTO in >> very >> imaginatve ways. >> >>> The "benefit" is easier to read code. >> >> I think that an immediate return is easier to read, but what do I know - >> I've only been programming for 30 years. >> >> -- >> Tony Marston > > Tony: > > Don't get your panties in a knot. :-) I think in Tony's case, it would "knickers in a twist". ;-} Paul -- Paul M. Foster

« previous php.general (#291876) next »