why is get not giving me a default value?

2012-10-18 Thread larry google groups
I have some Javascript on a website that pings my Clojure app. My app adds in the user info like this: (defn add-to-logged-in-registry [this-users-params] We assume some user is looking at a site such as wpquestions.com and the Javascript on that site is sending an Ajax request to this app,

Re: why is get not giving me a default value?

2012-10-18 Thread Tassilo Horn
larry google groups lawrencecloj...@gmail.com writes: (let [right-now (. (Date.) getTime) new-user-entry (conj this-users-params { updated right-now })] (swap! registry (fn [map-of-user-maps] (assoc (assoc map-of-user-maps (get new-user-entry username

Re: why is get not giving me a default value?

2012-10-18 Thread Toby Crawley
Does new-user-entry include a username entry that points to nil? get only uses default value if the key is not present: user= (get {:x nil} :x :not-found) nil user= (get {:x nil} :y :not-found) :not-found user= (or (get {:x nil} :x) :not-found) :not-found user= On Oct 18, 2012, at 10:11 AM,

Re: why is get not giving me a default value?

2012-10-18 Thread larry google groups
Okay, this is very confusing to me. If I try this: (defn add-to-logged-in-registry [this-users-params] (let [right-now (. (Date.) getTime) new-user-entry (conj this-users-params { updated right-now })] (swap! registry (fn [map-of-user-maps] (conj

Re: why is get not giving me a default value?

2012-10-18 Thread Nate Young
On Thu, Oct 18, 2012 at 10:16 AM, larry google groups lawrencecloj...@gmail.com wrote: Okay, this is very confusing to me. If I try this: (defn add-to-logged-in-registry [this-users-params] (let [right-now (. (Date.) getTime) new-user-entry (conj this-users-params { updated

Re: why is get not giving me a default value?

2012-10-18 Thread Sean Corfield
I tried your code and got the expected result: user (def registry (atom {})) #'user/registry user (import 'java.util.Date) java.util.Date user (defn add-to-logged-in-registry [this-users-params] (let [right-now (. (Date.) getTime) new-user-entry (conj this-users-params { updated

Re: why is get not giving me a default value?

2012-10-18 Thread larry google groups
Interesting. I am using Clojure 1.3. And I'm using clojure-jack-in inside of emacs. What are you using? On Thursday, October 18, 2012 11:22:26 AM UTC-4, Sean Corfield wrote: I tried your code and got the expected result: user (def registry (atom {})) #'user/registry user (import

Re: why is get not giving me a default value?

2012-10-18 Thread Sean Corfield
On Thu, Oct 18, 2012 at 8:26 AM, larry google groups lawrencecloj...@gmail.com wrote: Interesting. I am using Clojure 1.3. And I'm using clojure-jack-in inside of emacs. What are you using? I was using Clojure 1.4 via jack-in from emacs. I just tried it again with lein repl in a clean