I am not sure what exactly you're asking since you are already using 'doto' in your example so you already know what it does...Personally I would do something like this:

(defn make-sphere [&{:keys [color position]
                     :or {color 'white
                          position 0 0 0}}]
(let [sphere (mesh.sphere.)]
(doto sphere
     (.SetColor color)
     (.SetPosition position)
     (...)
     (...)
     (...)
)))


Jim

ps: 'doto' will give you back the object and will not ask you to repeat the name in every expression following (as opposed to 'do' where you have to return it explicitely via the last expression).

On 23/06/12 14:21, Antonio Recio wrote:
I create a white sphere at the beginning of my code, and later, after some lines of code, I change the color and the position of this sphere.

(def sphere (doto (mesh.sphere.)
  (.SetColor white))

(...)
(...)
(...)

(.. sphere SetColor red)
(.. sphere SetPosition 5 5 0))


To change the color and the position I need to repeat "sphere" each time. Is there any way to avoid repeat "sphere" each time, for example using "doto"?

(def sphere (doto (mesh.sphere.)
  (.SetColor white))

(...)
(...)
(...)

(doto sphere
  (.SetColor red)
  (.SetPosition 5 5 0))
--
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


--
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

Reply via email to