In Eclipse, is there any way to find which return statement a method returned from without logging flags at every return statment?
For example:
@Override
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof ABC)) {
return false;
}
ABC other = (ABC) obj;
if (var1 == null) {
if (other.var1 != null) {
return false;
}
} else if (!var1.equals(other.var1)) {
return false;
}
return true;
}
In this case, how do I find out at which point my equals method returned?
No, but a more understandable and debug friendly code can be with a boolean local variable that represents the result.
then you can see with debugger who assign it when and the return value before returned.
No. This is one reason that some people prefer single point of exit: Why should a function have only one exit-point?
Note also the links in the first comment on that question.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With