Hacker News new | ask | show | jobs
by iainmerrick 3424 days ago
What makes it clearer? I think you're just more used to "match", whereas other people are more used to "if".

The structure is almost identical. You even have an "else" clause!

1 comments

:else is a convention in Clojure that has truthy keywords. You could replace that with anything that evaluates to true, like :foo, or true, or 1, etc.
But don't you see what I'm saying? I assume the order is important, and if the else: (or whatever else you decide to use) were first it would match everything and prevent the other cases from being used. So it's exactly equivalent to an if/elif/else chain. The structure is the same.
Things can be semantically equivalent but more elegant, easier to read, and harder to make mistakes.

I think most function programmers are actually very familiar with the patters found in Java. It's often one of the reasons they fell in love with more functional styles of programming.