6 ms·
So it is more about multiple returns, versus setting some local return variable and returning in one place. However, setting that return variable can be recogn
by kazinator 2y ago
So it is more about multiple returns, versus setting some local return variable and returning in one place.
However, setting that return variable can be recognized as a simulated return. If we know that after "ret = 42", there are no other state changes; that the whole if/else mess will drop out to the end where there is a "return ret", then we can just read it as "return 42".
- fenomas 2y agoSure, in the narrow case where the function only calculates a single return value and has no side effects.