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

I don’t disagree with the essay, and I do generally dislike “unless” as it’s a cutesy statement which does not pull its weight (it would probably be better if there was no “else” clause at all).

However I find some of the examples / justifications unfortunate e.g.

> I find the second option less readable because it suggests that raising the error would be the normal thing to do, when in fact it’s the exceptional thing to do.

It’s not tho. The normal thing to do is to reject access, being an admin is exceptional. A restricted endpoint should absolutely assume the user is not authorised.



Fair enough argument for that particular example, but I think the author's point still stands for the other example (if !user.suspended do send_email end)


That example makes more sense as:

  send_email unless user.suspended?
Here we see that we normally send email - except for the exceptional case of the user being suspended.




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

Search: