On Fri, Oct 19, 2012 at 9:10 AM, larry google groups <
lawrencecloj...@gmail.com> wrote:

> Assume data that looks like this:
>
> {ziri {:last_name ziri, :image ziggy_stardust.jpg, :username larry,
> :first_name larry, updated 1350626694791}, 7777erich {:last_name 77777ich,
> :image 77777ot_mein.jpg, :username 7777erich, :first_name 7777754545_halle,
> updated 1350626679436}}
>
>
> When fed into the next function, the data looks like this:
>
> {:last_name 77777ich, :image 77777ot_mein.jpg, :username 7777erich,
> :first_name 7777754545_halle, updated 1350626679436}
>
> The function looks like this, but I can not get the if statement to ever
> run as if true.
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
>         new-user-entry (conj this-users-params { "updated" right-now })]
>
so if you replace this:

>     (if (:username new-user-entry)
>       (swap! registry assoc (:username new-user-entry) new-user-entry))))
>
with like (println (:username new-user-entry)) or even just
(println new-user-entry)
do you see what's expected? I imagine on the latter you would see this?
{:last_name 77777ich, :image 77777ot_mein.jpg, :username 7777erich,
:first_name 7777754545_halle, updated 1350626679436}

>
> The if statement seems to never be true.
>
> I also tried:
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
>         new-user-entry (conj this-users-params { "updated" right-now })]
>     (if-not (nil? (:username new-user-entry))
>       (swap! registry assoc (:username new-user-entry) new-user-entry))))
>
>
> and I tried this with "contains":
>
> (defn add-to-logged-in-registry [this-users-params]
>   (let [right-now (. (Date.) getTime)
>         new-user-entry (conj this-users-params { "updated" right-now })]
>     (if (contains?  new-user-entry :username))
>       (swap! registry assoc (:username new-user-entry) new-user-entry))))
>
> But it seems as if the branch following the if statement is never run, no
> matter what I do.
>
> Why?
>
>
>
>  --
> 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




-- 
I may be wrong or incomplete.
Please express any corrections / additions,
they are encouraged and appreciated.
At least one entity is bound to be transformed if you do ;)

-- 
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