Hi Andy

On clojurescript.net

running this:

[(= "ab" "ab")
(= "ab" (str "a" "b"))
(= :ab :ab)
(= :ab (keyword (str "a" "b")))]

output: [true true true true]

running this:

[(identical? "ab" "ab")
(identical? "ab" (str "a" "b"))
(identical? :ab :ab)
(identical? :ab (keyword (str "a" "b")))]

output: [true true true true]

What am I supposed to see here...?



On Fri, Apr 10, 2015 at 12:10 PM, AndyR <andre.r...@gmail.com> wrote:

> I think it's because of the test for equality. I still like the official
> clojure page for explanations:
> http://clojure.org/data_structures#Data%20Structures-Keywords
>
> Run a few experiments in a repl:
>
> 1 (identical? "ab" "ab")
> 2 (identical? "ab" (str "a" "b"))
> 3 (identical? :ab :ab)
> 4 (identical? :ab (keyword (str "a" "b")))
>
> Run the same with (= ...) and observe.
>
> (1 tests true since the JVM also has a string pool IIRC)
>
> HTH
>
> On Friday, April 10, 2015 at 2:51:09 PM UTC-4, marc fawzi wrote:
> > I just noticed that maps where key and value are keywords are used
> widely, for example in cljs-ajax and leinnigen configuration
> >
> >
> > Ii'm assuming it's because it's easier to work with values that are
> keywords to build other maps from them or do whatever transformations that
> result in values becoming keys in the output... and so it's explicit. But
> maybe I'm missing the real reason?
> >
> >
> > Is there a good nerdy blog about Clojure that gets into the finer
> details of Clojure for those of us who want to turn every atom?
>
> --
> Note that posts from new members are moderated - please be patient with
> your first post.
> ---
> You received this message because you are subscribed to the Google Groups
> "ClojureScript" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to clojurescript+unsubscr...@googlegroups.com.
> To post to this group, send email to clojurescript@googlegroups.com.
> Visit this group at http://groups.google.com/group/clojurescript.
>

-- 
Note that posts from new members are moderated - please be patient with your 
first post.
--- 
You received this message because you are subscribed to the Google Groups 
"ClojureScript" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojurescript+unsubscr...@googlegroups.com.
To post to this group, send email to clojurescript@googlegroups.com.
Visit this group at http://groups.google.com/group/clojurescript.

Reply via email to