0

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!

1

1 Answer 1

1
 (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))
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.