|
Re: Unnecessary Else Clause. [message #159729 is a reply to message #159625] |
Fri, 21 May 2004 00:59 |
Eclipse User |
|
|
|
Originally posted by: skoehler-remove-for-no-spam.upb.de
Vince wrote:
> A statement such as the following:
>
> if (condition)
> return 1;
> else
> return 2;
>
> can throw up the warning (if user preferences include the option):
> "Statement unnecessarily nested within else clause. The corresponding
> then clause doe not complete normally."
It does just mean, that your code is equivalent to
if (condition)
return 1;
return 2;
> Whilst the first statement is true can someone point me to a source of
> information that would confirm the second part - about the abnormal
> completion?
Well, the code "return 1;" doesn't complete (normally), since the VM
will never reach any code behind the return-statement.
|
|
|
|
|
Re: Unnecessary Else Clause. [message #160117 is a reply to message #159968] |
Sun, 23 May 2004 04:25 |
Eclipse User |
|
|
|
Originally posted by: akiezun.cuthis.mit.edu.andthis
> Vince wrote:
> > A statement such as the following:
> >
> > if (condition)
> > return 1;
> > else
> > return 2;
> >
> Probably not a good idea anyway: it is much clearer to have only one
> return, at the end, and change the return value with if/else statements
> along the way.
you sure ?
that'd be really ugly and not clean at at all - the 2 returns in the code
above is _much_ better, imo
a.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03200 seconds