Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.



It 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


It isn't (isDone = isDelivered) and isNotified, it's isDone = (isDelivered and isNotified). It's just an expression being assigned to a variable.


Ah ok, great, thanks.


I tend to agree that, given compiler doesn’t care most of time, saving characters can’t justify decrease in readability.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: