You have 3 choices, all supporting a -n optional default value:
1. (:kw m),
2. (m :kw),
3. (get m :kw)

If your keyword is literal, always pick #1.

So if your keyword is not literal then you are left with either (m x) or
(get m x) -- remember x is not litteral.
The later version will work with maps, records, vectors, sets and nil -- or
even anything. The former version will work with anything which is a
function (maps, sets, vectors and... fns).
So it boils down to: do you consider your map as a handy shorthand for a fn
(pick #2) or as a collection (pick #3)

Christophe


On Tue, Jan 29, 2013 at 11:24 AM, Meikel Brandmeyer (kotarak)
<[email protected]>wrote:

> For completeness sake...
>
> Am Dienstag, 29. Januar 2013 10:31:18 UTC+1 schrieb lpetit:
>
>> Rationale for b): you have an existing map, but the key may or may not
>> be present. Note that you can also use the version which returns
>> default value if there's no key in the map: (map key default-value)
>>
>
> Also, "key" may be of arbitrary type. Not necessarily a keyword.
>
> Meikel
>
>
> --
> --
> 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/groups/opt_out.
>
>
>



-- 
On Clojure http://clj-me.cgrand.net/
Clojure Programming http://clojurebook.com
Training, Consulting & Contracting http://lambdanext.eu/

-- 
-- 
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/groups/opt_out.


Reply via email to