Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Make disj nil-aware

Refers #360

Signed-off-by: Stuart Halloway <stu@thinkrelevance.com>
  • Loading branch information...
commit 7bf68461de66ef2d204487e345b2af18418ea581 1 parent fb52b69
@kotarak kotarak authored stuarthalloway committed
View
12 src/clj/clojure/core.clj
@@ -1168,12 +1168,14 @@
{:added "1.0"}
([set] set)
([^clojure.lang.IPersistentSet set key]
- (. set (disjoin key)))
+ (when set
+ (. set (disjoin key))))
([set key & ks]
- (let [ret (disj set key)]
- (if ks
- (recur ret (first ks) (next ks))
- ret))))
+ (when set
+ (let [ret (disj set key)]
+ (if ks
+ (recur ret (first ks) (next ks))
+ ret)))))
(defn find
"Returns the map entry for key, or nil if key not present."
View
4 test/clojure/test_clojure/data_structures.clj
@@ -728,6 +728,7 @@
; identity
(are [x] (= (disj x) x)
+ nil
#{}
#{1 2 3}
; different data types
@@ -753,6 +754,9 @@
(sorted-set 1 2) )
(are [x y] (= x y)
+ (disj nil :a) nil
+ (disj nil :a :b) nil
+
(disj #{} :a) #{}
(disj #{} :a :b) #{}
Please sign in to comment.
Something went wrong with that request. Please try again.