Hacker News new | ask | show | jobs
by michaelteter 1019 days ago
I wonder... why do the boolean coersion operators even exist since there are stricter (non-coersion) alternatives?

Granted, not providing an "if" would shock many people, but the "case" alternative isn't terrible.

But since this example is about misinterpreting return values (judging truthiness of :ok vs {:error, ...}), having explicit return types would solve this problem as well.

And not to start the war again, but as much as I admired Rich Hickey and his convincing talks, I am now a big fan of explicitly stated types for the clarity they provide the reader of a codebase. It's more of a chore to write, but it makes reading and understanding much better for me.