Monday, 8 December 2008
Clojure Java Interop
Use the "/" notation to call static methods
Use the "." operator to call instance methods
(Math/pow 2 3) ; 8
(Integer/toBinaryString 10) ; "1010"
;; not good style!
(. Integer toBinaryString 10) ; legal syntax but / operator preferred for clarity!
Use the "." operator to call instance methods
(. "shoes" length) ; 5
(. "1234abcd" substring 0 4) ; "1234
Labels: clojure
Subscribe to Posts [Atom]