This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-12-21
Channels
- # adventofcode (60)
- # aleph (2)
- # announcements (3)
- # architecture (2)
- # babashka (12)
- # beginners (90)
- # calva (14)
- # cider (32)
- # clj-kondo (1)
- # clj-together (7)
- # cljsrn (4)
- # clojars (10)
- # clojure (161)
- # clojure-dev (110)
- # clojure-europe (58)
- # clojure-nl (3)
- # clojure-spec (35)
- # clojure-taiwan (1)
- # clojure-uk (24)
- # clojuredesign-podcast (3)
- # clojurescript (27)
- # conjure (47)
- # cursive (17)
- # data-science (1)
- # datomic (1)
- # depstar (6)
- # fulcro (20)
- # java (4)
- # jobs-rus (1)
- # luminus (4)
- # malli (10)
- # off-topic (8)
- # re-frame (4)
- # reagent (1)
- # reitit (9)
- # reveal (1)
- # rewrite-clj (8)
- # ring (3)
- # sci (44)
- # shadow-cljs (5)
- # spacemacs (6)
- # specter (8)
- # tools-deps (6)
- # vim (1)
- # xtdb (11)
Hi,
is there a way to distinguish between a path not found and a path-value with nil
? like get-in
with default value?
(get-in {"foo" nil} ["foo"] :not-found) ;;=> nil
(get-in {"bar" nil} ["foo"] :not-found) ;;=> :not-found
(select ["foo"] {"foo" nil}) ;;=> [nil]
(select ["bar"] {"foo" nil}) ;;=> [nil]
@bruno.bonacci use the must
navigator
ok, however must
uses contains?
which fails if it not a map
so i have to put a guard predicate on every nesting to check that is a map
like [(pred map?) (must "foo") (pred map?) (must "bar") (pred map?) (must "baz")]
example:
(get-in {"foo" 1} ["foo" "bar"] :not-found) ;;=> :not-found
(select [(must "foo") (must "bar")] {"foo" 1})
throws:
Execution error (IllegalArgumentException) at com.rpl.specter.navs$fn$reify__33786/select_STAR_ (navs.cljc:655).
contains? not supported on type: java.lang.Long