(keys x) is a lazy seq so in (try (keys x) true), the (keys x) is created 
but not realized so the error is not discovered. The REPL will print the 
result, which requires the values to be realized.


On Friday, April 22, 2016 at 3:37:07 PM UTC-5, Steve Riley wrote:
>
> I am trying to determine if a container, x, passed to a function, is a map 
> or not.
>
> If I evaluation (keys x) at a REPL prompt, and, x is instantiated list, 
> vector or set, I will get a java.lang.ClassCastException that some item in 
> x cannot be cast to java.util.Map$Entry.
>
> On the other hand, if I evaluate (try (keys x) true), the form evaluates 
> to true. It will also evaluation to true if I add a catch expression with 
> the last value of false. I've tried catching both ClassCastException and 
> just Exception.
>
> (try (/ 10 0) true (catch ArithmeticException _ "divide by zero!")) 
> and (try (/ 10 1) true (catch ArithmeticException _ "divide by zero!")), 
> for example, evaluate as expected.
>
> Is this a feature I don't understand?
>
> Some of you may recognize the 4Clojure problem I am working on. I'm not 
> interested in solutions to that problem...just curious about this behavior 
> and if there is something I am missing in the try (keys x) catch 
> formulation.
>
> Many thanks 
>

-- 
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
--- 
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 clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to