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 points of this here:
http://stackoverflow.com/questions/7034803/idiomatic-clojure-map-lookup-by-keyword
Erik.
> On 13 Sep 2016, at 11:49, 'Rickesh Bedia' via Clojure
> <[email protected]> wrote:
>
> Hi everyone,
>
> I am new to Clojure and have been playing around with it for a little while.
> I have seen that (get [3 2 1] 0) and ([[3 2 1] 0) both return the value 3.
> Similarly (get {:a 0 :b 1} :b) and ({:a 0 :b 1} :b) return 1.
>
> I was wondering if anyone could explain why the get function is useful or
> maybe an example?
>
> Apologies in advance if this question is due to ignorance and I haven't
> reached the level where this function is used.
>
> Thanks in advance
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
---
You received this message because you are subscribed to the Google Groups
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.