File tree 2 files changed +12
-3
lines changed
2 files changed +12
-3
lines changed Original file line number Diff line number Diff line change 198
198
" Recursively merges maps."
199
199
[& maps]
200
200
(letfn [(m [& xs]
201
- (if (every? #(and (map? %) (not (record? %))) xs)
202
- (apply merge-with m xs)
203
- (last xs)))]
201
+ (let [xs (remove nil? xs)]
202
+ (if (every? #(and (map? %) (not (record? %))) xs)
203
+ (apply merge-with m xs)
204
+ (last xs))))]
204
205
(reduce m maps)))
Original file line number Diff line number Diff line change 158
158
nil 3 7 ))
159
159
160
160
(deftest deep-merge-test
161
+ (is (= (core/deep-merge {:foo 1 } nil )
162
+ {:foo 1 }))
163
+ (is (= (core/deep-merge nil {:foo 1 })
164
+ {:foo 1 }))
165
+ (is (= (core/deep-merge {:foo 1 } {:foo nil })
166
+ {:foo 1 }))
167
+ (is (= (core/deep-merge {:foo nil } {:foo 1 })
168
+ {:foo 1 }))
161
169
(is (= (core/deep-merge {:foo {:bar 1 }} {:foo {:baz 2 }})
162
170
{:foo {:bar 1 :baz 2 }}))
163
171
(is (= (core/deep-merge {:foo {:bar 1 }} {:baz 2 })
You can’t perform that action at this time.
0 commit comments