From 8a55ebccc035e344c42009ce35d42d65b87aa74b Mon Sep 17 00:00:00 2001 From: Michael Fogleman Date: Mon, 11 Sep 2017 11:06:45 -0400 Subject: [PATCH] Document map-key. --- List-of-Navigators.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/List-of-Navigators.md b/List-of-Navigators.md index 10f3edf..980b050 100644 --- a/List-of-Navigators.md +++ b/List-of-Navigators.md @@ -38,6 +38,7 @@ - [if-path](#if-path) - [index-nav](#index-nav) - [keypath](#keypath) + - [map-key](#map-key) - [multi-path](#multi-path) - [must](#must) - [nil->val](#nil-val) @@ -558,6 +559,33 @@ See also [must](#must) [0 :boo] ``` +## map-key + +`(map-key key)` + +Navigates to the given key in the map (not to the value). + +```clojure +=> (select [(map-key :a)] {:a 2 :b 3}) +[:a] +=> (setval [(map-key :a)] :c {:a 2 :b 3}) +{:b 3, :c 2} +``` + +Navigates only if the key currently exists in the map. + +```clojure +=> (select [(map-key :z)] {:a 2 :b 3}) +[] +``` + +Can transform to NONE to remove the key/value pair from the map. + +```clojure +=> (setval [(map-key :a)] NONE {:a 2 :b 3}) +{:b 3} +``` + ## multi-path `(multi-path & paths)`