When I use if-let like
(if-let [a 2 b nil] (+ ab))
I get an IllegalArgumentException:
clojure.core/if-let requires exactly 2 forms in binding vector...
Similarly for if-let ...
This is not what I would expect. If-let could try all the bindings and break if someone fails and evaluates the else statement.
The same complaints can be found in the comments on clojuredocs . I found an answer here that didn't really satisfy, since the poster seems to have the equivalent of a nested if-let-structure.
What are the reasons for limiting * -let macro bindings?
UPDATE: It seems incomprehensible to me what are my expectations from if-let:
- He must evaluate all the bindings sequentially.
- When everything succeeds, it must evaluate the βthatβ case.
- If one binding fails, it should immediately break and evaluate the "else".
- In case of failure, bindings, even successful ones, should not be available in 'else'-expression
source share