4 ms·
Is anyone willing to explain the second line? I get the first means "if isDelivered and isNotified are both true then set isDone to True, if not set it to false
by drchewbacca 7y ago
Is anyone willing to explain the second line? I get the first means "if isDelivered and isNotified are both true then set isDone to True, if not set it to false". However I've never seen a variable being set "isDone = isDelivered" as part of a logical test.
Personally I think programmers who are "too clever" are cancer inside a codebase. Sure you saved a bunch of keystrokes but your code golf has locked the code forever unless someone is willing to rewrite it. This is not a bad example but in general I think people who strive to do things in less characters are highly problematic.
- whiddershins 7y agoIt feels clever if you aren’t used to it but it is super common. isDelivered && isNotified always resolves to a Boolean, either TRUE or FALSE So you are just saying isDone = TRUE or isDone = FALSE that’s all
- LaserToy 7y agoI tend to agree that, given compiler doesn’t care most of time, saving characters can’t justify decrease in readability.
- edflsafoiewq 7y agoIt isn't (isDone = isDelivered) and isNotified, it's isDone = (isDelivered and isNotified). It's just an expression being assigned to a variable.
- drchewbacca 7y agoAh ok, great, thanks.