--
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
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
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 unsubscribe from this group and stop receiving emails from it, send an email to clojure+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I agree about the counter-intuitiveness. I'm only wondering whether the error message is a bit misleading "contains? not supported on type: java.lang.String" because of course (contains? "hello" 2) works fine.
On May 12, 2015, at 4:28 PM, Fluid Dynamics <a209...@trbvm.com> wrote:
On Tuesday, May 12, 2015 at 3:34:46 PM UTC-4, Michael Gardner wrote:
On May 12, 2015, at 1:54 PM, Shantanu Kumar <kumar.s...@gmail.com> wrote:
> I agree about the counter-intuitiveness. I'm only wondering whether the error message is a bit misleading "contains? not supported on type: java.lang.String" because of course (contains? "hello" 2) works fine.
Can anyone comment on why Strings are explicitly supported here?
Strings and arrays support constant-time access by index. The thing that's broken is "contains? not supported on type: java.lang.String" instead of nil when a nonnumeric key is used. One gets nil with a nonnumeric key and a PersistentVector, rather than an exception.
> (get "the char at index" 4)
\c
e
I always assumed (contains? "foo" 2) worked because strings are arrays (i.e. vectors) of characters, on some level.