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

The unless is still harder for me to grok.

The if !ruby_dev (read as "if not ruby_dev") is so much easier.



For some reason this one feels right to express with if-not to me too.

The one place I’ll often use unless is things like:

    return unless valid

    raise unless h.key?(k)
I think it might have something to do with:

1. How abundantly clear it is that the condition is a Boolean; and

2. The “false” condition indicating a “no work to do” situation.

I think I only use them for postfix return, break, next, and raise.


Fascinating! I find it slightly easier to understand "unless" than "if not". But only oh-so slightly, and probably not enough to justify making it harder for others to read my code.




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

Search: