Hi, Can someone teach me how I can override the "toString" method for a struct ?
Here's a code snippet that shows what I'm trying to do: user> (defstruct bookinfo :book :filename) user> (struct bookinfo "hello" "world") => {:book "hello", :filename "world"} I would like to override the "toString" method on a struct so that the following behavior is true: user> (struct bookinfo "hello" "world") => "hello" In Common Lisp, I would simply define a method on (print-object). What would be the equivalent thing in Clojure? I already tried the following but it doesn't seem to work (sorry...i've been programming Clojure for only two days): user> (defmulti .toString class) user> (defmethod .toString clojure.lang.PersistentStructMap [s] (:book s)) Thanks for your help. Regards, Jung Ko --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---