4 ms·
> if item not in collection # travesty! > if ! (item in collection) # ok Riiiiiiiight. No more language suggestions from you, thanks ;)
by Benjamin_Dobell 11y ago
> if item not in collection # travesty!
> if ! (item in collection) # ok
Riiiiiiiight. No more language suggestions from you, thanks ;)
- deleted 11y ago[deleted]
- ForHackernews 11y agoI believe the parent comment is agreeing with you (?) and disagreeing with the author of the linked article.
- LouisSayers 11y agoAgreed > if item not in collection reads quite nicely. I don't see what the problem is there? Anyway, I don't think his one gripe with this is enough reason to throw the rest of his argument out.
- freditup 11y agoI actually find that the use of "!" over "not" improves readability. English words tend to all blend together and take more time to parse, whereas a nice "!" token is easy to recognize at a glance. That being said, "not" is of course more understandable for somebody who has no idea about the language; however, asking a programmer to learn a single symbol for "not" is not too much to ask :)
- wohlben 11y agodepends how much attention you're paying at the moment. its easier to miss a ! than a 'not' at a quick glance
- singularity2001 11y agogood point! all syntax highlighters should color negations in neon red
- theodorton 11y agounless item in collection Obviously is the best choice
- pmontra 11y agoYes, and it's the idiomatic Ruby one.
- LouisSayers 11y agoTouché ;)
- deleted 11y ago[deleted]
- singularity2001 11y ago>> if item not in collection he should have suggested if not item in collection which should then work out of the box anyways [I completely agree with the need for the 'in' operator]