Reputation: 1197
I was following the example on Clojure in Action Page 326,
(defn new-object [klass]
(fn [command & args]
(condp = command
:class klass)))
Then I typed: (def cindy (new-object Person))
It gives me: CompilerException java.lang.RuntimeException: Unable to resolve symbol: Person in this context, compiling:(/Users/sdfsd/clj/testlein/src/testlein/sdf:22:12)
If I change Person to "Person" or 'Person, it works. But I believe that is not the right way to solve this problem because Person should be a class and "Person" is :name of the class. Could someone please tell me why I am having this problem? Thanks!
Upvotes: 0
Views: 106
Reputation: 3061
(import package-and-name-of-your-person-class)
Or without import, use as parameter in the function call package-and-name-of-your-person-class instead of Person
(def cindy (new-object package-and-name-of-your-person-class))
Upvotes: 1