Sorry, I copied the wrong snippet from my repl - the correct one is:

...
user> (= (.getBytes "a")(.getBytes "a"))
false
user> (= (seq (.getBytes "a")) (seq (.getBytes "a")))
true
...

although the previous extra "(bytes...)" doesn't change the example, it may add 
to the confusion ;-)

-FS/



On Mar 23, 2010, at 10:24 AM, Frank Siebenlist wrote:

> My REPL shows:
> ...
> user> (= (bytes (.getBytes "a"))(bytes (.getBytes "a")))
> false
> user> (= (seq (bytes (.getBytes "a"))) (seq (bytes (.getBytes "a"))))
> true
> ...
> 
> in other words, "equality" for java byte arrays is defined differently than 
> their seq'ed version.
> 
> It seems that the native arrays are compared on their reference while the 
> seq'ed version on their value (as it should...).
> 
> Sometimes the seq'ing seems implied, however, like in:
> 
> ...
> user> (first (bytes (.getBytes "a")))
> 97
> ...
> 
> but for the "=" function it is not.
> 
> This doesn't feel right and is confusing to say the least.
> 
> Could anyone shed some light on this behaviour?
> 
> Thanks, Frank.
> 

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

To unsubscribe from this group, send email to 
clojure+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to