Skip to content
This repository has been archived by the owner on Mar 8, 2021. It is now read-only.

Minor code improvement for the gets function #159

Open
beoliver opened this issue Mar 24, 2019 · 0 comments
Open

Minor code improvement for the gets function #159

beoliver opened this issue Mar 24, 2019 · 0 comments

Comments

@beoliver
Copy link

not really that important but the implementation of gets could be cleaner.
would make more sense to be implemented as

(defn gets
  "Returns the first value mapped to key found in the provided maps."
  [k & maps]
  (->> (map #(get % k) maps)
       (remove nil?)
       first))

As you are mapping and filtering nil will never be returned meaning that the threading will continue (= (list) (some->> (map identity []))). If get is used then the call to first will either be a value or nil.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant