Share your thoughts in the 2025 State of Clojure Survey!

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

+1 vote
ago in Clojure by
closed ago by

Is there a reason that sets (and vectors) don't have a not-found argument for invoke?

({:a :b} :c :not-found) ;;=> :not-found
user=> (#{:a :b} :c :not-found)
Execution error (ArityException) at user/eval1 (REPL:1).
Wrong number of args (2) passed to: clojure.lang.PersistentHashSet

In ClojureScript it's already implemented:

cljs.user=> (#{:a :b :c} :d :not-found)
:not-found

However not for vector:

cljs.user=>  ([] 0 :not-found)
Execution error (Error) at (<cljs repl>:1).
No item 0 in vector of length 0

If JIRA issue + patch is welcome for this, I'm volunteering.

1 Answer

0 votes
ago by

Dupe of https://ask.clojure.org/index.php/2833/optional-found-argument-when-invoking-vectors-sets-functions - please vote there if you're interested, happy for someone to refresh the jira+patch on https://clojure.atlassian.net/browse/CLJ-1305 too.

...