On 9/13/16, 5:02 AM, "Erik Assum" wrote:
> you’ll see that `get` accepts an additional argument, the default value,
> which e.g. the keyword does not.
Just FYI, both the keyword first form and the map first form do accept an
additional default argument:
boot.user> (:b {:a 1 :b 2} 3)
2
boot.us
The `get` function will accept `nil` as the map argument and return `nil`,
but invoking `nil` will throw a NullPointerException.
By convention, people use `get` when they don't know what the map argument
is, since it might be nil. And we use keywords as functions when they are
literals, like (:
From
https://clojuredocs.org/clojure.core/get
you’ll see that `get` accepts an additional argument, the default value, which
e.g. the keyword does not.
As for getting stuff out of maps, the idiomatic way is
(def m {:a 1 :b 2})
(:b m)
;; => 2
There is otherwise a nice discussion about the finer