refs, called as a function, try to call the value they hold as a
function with the given arguments

((first @my-contacts) :fname) ~= (:fname @(first @my-contacts))

basically you have two levels of refs, but are only derefing once, but
by happy accident ((first @my-contacts) :fname) works

On Wed, Oct 12, 2011 at 4:20 PM, qhfgva <qhf...@gmail.com> wrote:
> I was trying out an example from Practical Clojure and I don't
> understand why I get different results below?  Can someone enlighten
> me?
>
> user=> @my-contacts
> [#<Ref@1e26602: {:fname "Luke", :lname "VanderHart"}> #<Ref@8ca8ac:
> {:fname "Stuart", :lname "Sierra"}> #<Ref@7056d5: {:fname
> "John", :lname "Doe"}>]
> user=> (:fname (first @my-contacts))
> nil
> user=> ((first @my-contacts) :fname)
> "Luke"
>
> Why would the placement of :fname change how it looks up?  I would
> expect to need a deref to be able to get the "Luke" value.
>
> --
> 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



-- 
And what is good, Phaedrus,
And what is not good—
Need we ask anyone to tell us these things?

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