If a nil reaches, e.g., clojure.set/union
or clojure.set/intersection
, the output depends on the position. I think those functions should give back always a hash-set, irrespective of nil
s or the position of nil
.
$ clj
Clojure 1.10.3
user=> (require '[clojure.set :refer [intersection union]])
nil
user=> (union #{} nil)
#{}
user=> (union nil #{})
nil
user=> (intersection #{} nil)
#{}
user=> (intersection nil #{})
nil
user=> (union #{} nil nil)
nil
user=> (union nil #{} nil)
nil
user=> (union nil nil #{})
#{}
user=> (intersection #{} nil nil)
nil
user=> (intersection nil #{} nil)
nil
user=> (intersection nil nil #{})
#{}
I think the order of the arguments shouldn't matter and should always be a set, in my opinion, just assuming nil
as an empty set. Plus if one intends to call later (set-of-things thing)
an exception might arise (this is what bit me).
And maybe this is not limited to union and intersection only and more functions have this "issue"