ClojureDocs

Nav

Namespaces

..

clojure.core

Available since 1.0 (source)
  • (.. x form)
  • (.. x form & more)
form => fieldName-symbol or (instanceMethodName-symbol args*)
 Expands into a member access (.) of the first member on the first
argument, followed by the next member on the result, etc. For
instance:
 (.. System (getProperties) (get "os.name"))
 expands to:
 (. (. System (getProperties)) (get "os.name"))
 but is easier to write, read, and understand.
3 Examples
user> (.. "fooBAR" (toLowerCase) (contains "ooba"))
true

;; use macroexpand to see how the form above will appear
user> (macroexpand '(.. "fooBAR" (toLowerCase) (contains "ooba")))
(. (. "fooBAR" (toLowerCase)) (contains "ooba"))
user=> (.. "abc" toUpperCase (equals "ABC"))
;;=> true
;; With .. you do not need to add a . to your method.
(.. "fooBAR" (toLowerCase) (contains "ooba"))

;; Which you do if using -> instead.
(-> "fooBAR" (.toLowerCase) (.contains "ooba"))
See Also

Threads the expr through the forms. Inserts x as the second item in the first form, making a list ...

Added by didibus

Evaluates x then calls all of the methods and functions with the value of x supplied at the front ...

Added by manawardhana
0 Notes
No notes for ..