Why do maps and keywords both have an extra arity with a default argument, while sets don't?
Is this an implementation detail, or a specific design decision?
({:a 2} :b :not-found) ;;=> :not-found
(:b {:a 2} :not-found) ;;=> :not-found
;; This seems counter intuitive.
(#{:a} :b :not-found) ;;=> clojure.lang.ArityException
(:b #{:a} :not-found) ;;=> :not-found
I don't think there's any compelling reason: they certainly could, and it seems reasonable enough to me. The feature was added for maps and keywords in 3b7c1612, and hasn't been touched since; I guess it just wasn't included in that initial commit and there's been no great reason to revisit that decision since.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With