4 ms·
I always read that sort of if block as the mark of somebody who's been round the block a few times. Because they know that one day you'll want to place a breakp
by to3m 10y ago
I always read that sort of if block as the mark of somebody who's been round the block a few times. Because they know that one day you'll want to place a breakpoint on one case or the other, and they know that one day they'll want to know what the value of the condition is before it's used, and one day they'll want to put some logging in, and so on - and they know they won't thank their old selves for making that harder.
This sort of hard-won experience is how you get the high salaries, you know...
- cableshaft 10y agoWhile I agree it's often advantageous to set a local variable instead of just immediately returning an expression for breakpoint reasons, there's really no reason to have that if statement in there instead of just returning the local variable, and I think it reads poorly. It's trivial to add the if statement if it's truly necessary in the future (like if you need to evaluate the variable beyond simply whether to return true or false).