我遇到过几次:
try {
if (condition()) {
return simpleFunction(with, some, args);
} else {
return complexFunction(with, other, args);
}
catch (something) {
// Exception thrown from condition()
return complexFunction(with, other, args);
}
有什么方法(任何语言)可以避免重复调用 complexFunction?理想情况下不会掩盖代码的意图?