> My motivation is need to construct list of Java objects and I would > like to have some concise syntax to write them. So I decided to do > this with maps.
Perhaps something like this: (defn ^java.lang.reflect.Field get-field "Return Field object" [class-or-obj ^String field-name] (let [c (if (class? class-or-obj) class-or-obj (class class-or-obj)) f (.getDeclaredField c field-name)] (.setAccessible f true) f)) (defn as-str [a] (if (instance? clojure.lang.Named a) (name a) (str a))) (defn set-field-value [obj [field-name value]] (let [f (get-field obj (as-str field-name))] (.set f obj value) obj)) ;; returns the object (reduce set-field-value (Something.) {:id 10 :name "Impostor!"}) Regards, Shantanu -- 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