Carsten Ziegeler wrote:
Sylvain Wallez wrote:
Hi all,
I noticed for a while that many commits are related to "making Eclipse
happier" because of an additional 3.1 feature that flags "unnecessary
else statement".
These changes are for constructs such as:
if (condition) {
return foo;
} else {
return bar;
}
which are changed to:
if (condition) {
return foo;
}
return bar;
So please, update your settings and leave unchanged what doesn't need to
be changed :-)
Oh no, you're starting one of the famous code formatting threads...I'm
just waiting for someone pointing out that the brackets should be in a
new line...
Seriously, I think a method should only have *one single* return
statement, which makes imho code even more readable.
Really?
Object result;
if (condition) {
result = foo;
} else {
result = bar;
}
return result;
or also
Object result = bar;
if (condition) {
result = foo;
}
return result;
Doesn't look better to me.
Ok, I'll write "return cond ? foo : bar" from now on which is a single
return statement...
Sylvain
--
Sylvain Wallez Anyware Technologies
http://apache.org/~sylvain http://anyware-tech.com
Apache Software Foundation Member Research & Technology Director