> what's the preferred way to override the toString method of a > ClojureScript record? I could use set! to change the toString fn > of a record after it has been initialized like this: > > (defrecord MyRecord [name]) > > (let [record (MyRecord. "Hello World")] > (set! record.toString (fn [] (:name (js* "this")))) > (str record))
Not unlike Clojure, you can extend ClojureScript types to Object & nil as well. So you can do something like this - (defrecord MyRecord [name] Object (toString [_] name)) Regards, BG -- Baishampayan Ghose b.ghose at gmail.com -- 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