Welcome! Please see the About page for a little more info on how this works.

0 votes
in Clojure by
Maps, keywords, and symbols when used as operators allow optional second arguments for 'default-not-found' values is if to 'get'.


({:a 1} :b 'b) => b


However sets don't support this behavior (though they do with 'get') and vectors don't allow the optional default-not-found in their pseudo 'nth' semantics.


user=> (#{:a  :b} :b 'notfound)
ArityException Wrong number of args (2) passed to: PersistentHashSet  clojure.lang.AFn.throwArity (AFn.java:437)

6 Answers

0 votes
by

Comment made by: pepijndevos

I fixed the problem with Dirk at the Amsterdam Clojurians Hackathon.

0 votes
by

Comment made by: bozhidar

Guess you can add a couple of unit tests as well.

0 votes
by

Comment made by: dirklectisch

I have added some tests for the changes made earlier.

0 votes
by

Comment made by: abrooks

Is there something that is needed for these patches to be applied? I run into this semi-regularly.

0 votes
by

Comment made by: alexmiller

Sorry, has just never been looked at afaik. Votes help raise visibility.

0 votes
by
Reference: https://clojure.atlassian.net/browse/CLJ-1305 (reported by alex+import)
...