Reputation: 6194
I have written the following bit of code
(defn create [title url]
(when (not-any? clojure.string/blank? '(title url))
(println "doing stuff")))
However when I call the function
(create "title" "url")
I get the following error and cannot figure out what I am doing wrong
ClassCastException clojure.lang.Symbol cannot be cast to java.lang.CharSequence clojure.string/blank? (string.clj:279)
Upvotes: 0
Views: 1056
Reputation: 1339
This is one of the things that also tripped me up when I first started learning clojure. Basically, you should use
(list title url)
The clojure compiler treats
'(title url)
as
(quote (title url))
'quote' does not evaluate anything inside of it, so 'title' and 'url' are just symbols (clojure.lang.Symbols to be precise).
Here's a better explanation than mine: http://blog.8thlight.com/colin-jones/2012/05/22/quoting-without-confusion.html
Upvotes: 3