On 24 December 2013 07:35, Michał Marczyk wrote:
> ;; persistent maps only
> (instance? clojure.lang.IPersistentMap %)
Additionally, this one's better written
(map? %)
(map? is in fact defined as instance? IPM.)
Cheers,
M.
>
> ;; all Java maps
> (instance? java.util.Map %)
>
> On 24 December
;; persistent maps only
(instance? clojure.lang.IPersistentMap %)
;; all Java maps
(instance? java.util.Map %)
On 24 December 2013 04:28, larry google groups
wrote:
> I find this surprising. I do this:
>
> (supers %)
>
> inside of my :post condition, and I get:
>
> java.lang.ClassCastException:
You mean (supers (type %)) ?
Sean Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org
From: larry google groups
Sent: Monday, December 23, 2013 7:28 PM
To: clojure@googlegroups.com
I find this surprising. I do this:
(supers %)
inside of my :post condition,
I find this surprising. I do this:
(supers %)
inside of my :post condition, and I get:
java.lang.ClassCastException: clojure.lang.PersistentHashMap cannot be cast
to java.lang.Class
at clojure.core$bases.invoke(core.clj:4985)
at clojure.core$supers.invoke(core.clj:4994)
at admin.secretary$fetc
> enforce that the return is a subtype of java.util.Map rather than
checking for a specific concrete class of map.
Thank you. I'll do that. All the same, can anyone tell me why this function
changes the type of the value? All it does is call "fetch". The fetch
function has this post condition:
The two classes have essentially the same semantics, but performance
differences, which is why Clojure sometimes uses one and sometimes the
other. If you want to enforce that a map is returned, enforce that the
return is a subtype of java.util.Map rather than checking for a specific
concrete class
Hmm, I see. get-distinct was returning an empty lazyseq, which apparently
made the difference.
On Sunday, December 22, 2013 2:56:01 PM UTC-5, larry google groups wrote:
>
> Hmm, the different return types seem tied to the 2 different functions
> being called, but both functions have the same r
Hmm, the different return types seem tied to the 2 different functions
being called, but both functions have the same return type, which is a
lazyseq. I am using Monger to get data from MongoDb. These functions are
private:
(defn- get-distinct [request]
{:pre [(= (type request) clojure.lang.P