3 ms·
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 t
by masklinn 4y ago
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.
- dkdbejwi383 4y agoFair 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)
- e12e 4y agoThat 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.