Hi, Running the following test code generates an exception: =>(def foo (sorted-set "bob" "alice" "michael")) => (contains? foo 5) java.lang.ClassCastException: java.lang.String cannot be cast to java.lang.Number (NO_SOURCE_FILE:0)
I've tracked down the source of the exception to the method clojure.lang.Util.compare. This method will test whether the first argument is a number (which it is), and then perform Numbers.compare() on the two arguments. However the set contains strings, so when ops() is invoked on the second argument, the default value for an ops is INTEGER_OPS, which then barfs when the string is treated as an IntegerOps type. I don't know what is the policy of allowing users to shoot themselves in the foot. IMO Util.compare should not assume the second argument is a number when the first argument is a number. But I thought I would point out this behavior and elicit comments from the group. Thanks, --Michael --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---