Hello all,
I am new to clojure and I have two questions about do and the way it should
be used.
*Question 1: Which of the following two functions is more idiomatic and
why? Both functions produce the same result.*
<code>
(defn my-fn [java-object]
(. java-object firstFunc)
(. java-object secondFunc)
(. java-object thirdFunc)
java-object)
</code>
<code>
(defn my-fn [java-object]
(do (. java-object firstFunc)
(. java-object secondFunc )
(. java-object thirdFunc )
java-object))
</code>
*Question 2: Again, which one is more idiomatic and why? Both functions
produce the same result.*
*
*
<code>
(defn my-fn [java-object bar]
(let [bar-bar (. java-object getSomething)
_ (if (not (is-bar? bar))
(. java-object (setSomething bar-bar)))]
java-object))
</code>
<code>
(defn my-fn [java-object bar]
(let [bar-bar (. java-object getSomething)]
(do
(if (not (is-bar? bar))
(. java-object (setSomething bar-bar)))
java-object)))
</code>
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en