JanetDocsSign in with Github

get-in



    function
    boot.janet on line 1163, column 1

    (get-in ds ks &opt dflt)
    
    Access a value in a nested data structure. Looks into the data
    structure via a sequence of keys.


3 examplesSign in to add an example
Loading...
(get-in  {:a {:cc 2} :b {:dd 3}}  [:a]     42)  # => {:cc 2}
(get-in  {:a {:cc 2} :b {:dd 3}}  [:a :cc] 42)  # => 2

(get-in  {:a {:cc 2} :b {:dd 3}}  [0]  42)  # => 42
(get-in  {:a {:cc 2} :b {:dd 3}}  [:z] 42)  # => 42
cellularmitosis
(get-in  [[4 5] [6 7]]  [0]    42)  # => (4 5)
(get-in  [[4 5] [6 7]]  [0 1]  42)  # => 5

(get-in  [[4 5] [6 7]]  [-1]     42)  # => 42
(get-in  [[4 5] [6 7]]  [9 9 9]  42)  # => 42
cellularmitosis
(def request {:params {:id 1}}) # => {:params {:id 1}}

(get-in request [:params :id]) # => 1

(get-in request [:params :name]) # => nil

(get-in request [:params :name] "N/A") # => "N/A"
inchingforward