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 map-of-user-maps {:hi new-user-entry})))))

and then at the REPL I:

who-is-logged-in.core> @registry
{nil {:last_name "777ch", :image "7777in.jpg", :username "7777ch", 
:first_name "77777alle", "updated" 1350573104214}}

Here I am hard-coding a key called ":hi" and yet in the registry I still 
see the top level key as "nil". What happened to the :hi? I was expecting:


{:hi {:last_name "777ch", :image "7777in.jpg", :username "7777ch", 
:first_name "77777alle", "updated" 1350573104214}}


What am I not understanding? 




On Thursday, October 18, 2012 10:47:25 AM UTC-4, Toby Crawley wrote:
>
> 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, larry google groups 
> <lawrenc...@gmail.com<javascript:>> 
> wrote: 
>
> > 
> > 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, every 
> 10 seconds, with a map of information about the user, which we need to 
> store in the registry." 
> >   (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" "anonymous") {}) (get new-user-entry "username" "anonymous") 
>  new-user-entry))))) 
> > 
> > I wanted to get a map inside of a map like this: 
> > 
> > {:lawrence {:last_name "Krubner", :image "ziggy_stardust.jpg", :username 
> "lawrence", :first_name "Lawrence", "updated" 1350568598742}} 
> > 
> > instead I get: 
> > 
> > {nil {:last_name "Krubner", :image "ziggy_stardust.jpg", :username 
> "lawrence", :first_name "Lawrence", "updated" 1350568598742}} 
> > 
> > How can I get the username as the top level key, instead of "nil"? 
> > 
> > 
> > 
> > -- 
> > You received this message because you are subscribed to the Google 
> > Groups "Clojure" group. 
> > To post to this group, send email to clo...@googlegroups.com<javascript:> 
> > Note that posts from new members are moderated - please be patient with 
> your first post. 
> > To unsubscribe from this group, send email to 
> > clojure+u...@googlegroups.com <javascript:> 
> > 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 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