On Mar 20, 10:50 am, Andreas Kostler
<andreas.koestler.le...@gmail.com> wrote:
> I would like to throw an exception when I'm trying to retrieve a value in a 
> map for a key that doesn't exist.

Another concise solution (thanks, Conj Labs):

(defn get-o­r-exc [map key]
  (if-l­et [[_ v] (find­ map key)]­
    v
    (thro­w (Exce­ption. "miss­ing"))))

I'm not too fond of using exceptions for flow control, though.

Daniel

-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to