Just a quick straw-poll really:
What is your take on using 'return' when you end a function, if you
don't actually need to return a value?
If you have to return say a true/false as the result of an operation,
then it's an obvious choice. But what if all the function does is
perform an
If there is no need to return a value then I don't do so. However, the
function is going to process something, and surely you should check that the
processing has succeeded or failed?
On Wed, 2007-05-30 at 12:20 +0100, Dave Goodchild wrote:
If there is no need to return a value then I don't do so. However, the
function is going to process something, and surely you should check that the
processing has succeeded or failed?
If you unit test, then returns become quite
2007. 05. 30, szerda keltezéssel 11.52-kor Richard Davey ezt írta:
Hi all,
Just a quick straw-poll really:
What is your take on using 'return' when you end a function, if you
don't actually need to return a value?
If you have to return say a true/false as the result of an operation,
If there is no need to return a value then I don't do
so. However, the function is going to process something,
and surely you should check that the processing has
succeeded or failed?
This is precisely the point I was going to make. Unless an argument is
passed in by reference for
Chris Boget wrote:
If there is no need to return a value then I don't do
so. However, the function is going to process something,
and surely you should check that the processing has
succeeded or failed?
This is precisely the point I was going to make. Unless an argument is
passed in by
[snip]
All depends on the function.
function someFunc(){
$this-counter++;
if($this-counter 100) $this-counter = 0;
}
Something that simple wont need a return at all.
[/snip]
Classically this would need a return, because $this-counter is going to
be less than 100 most of the
On Wed, May 30, 2007 5:52 am, Richard Davey wrote:
Just a quick straw-poll really:
What is your take on using 'return' when you end a function, if you
don't actually need to return a value?
If you have to return say a true/false as the result of an operation,
then it's an obvious choice.
At 5/30/2007 05:41 AM, Richard Davey wrote:
/* check connection */
if (mysqli_connect_errno()) {
printf(Connect failed: %s\n, mysqli_connect_error());
exit();
}
If that was wrapped in a function, sticking 'return false' within the
connect_error check is useful why exactly? Equally the
On Wed, May 30, 2007 7:42 am, Darren Whitlen wrote:
Chris Boget wrote:
If there is no need to return a value then I don't do
so. However, the function is going to process something,
and surely you should check that the processing has
succeeded or failed?
This is precisely the point I was
On Wed, May 30, 2007 7:56 am, Jay Blanchard wrote:
Classically this would need a return, because $this-counter is going
to
be less than 100 most of the time, and you may want to return the
value
at some point.
Or you may not ever need to return it.
And if you return it for no reason, you
11 matches
Mail list logo