Returns a clone of the Java array. Works on arrays of known
types.
;; create an Java integer array, then clone it ;; note that when you modify b, a remains the same ;; showing that b is not just a reference to a user=> (def a (int-array [1 2 3 4])) #'user/a user=> (def b (aclone a)) #'user/b user=> (aset b 0 23) 23 user=> (vec b) [23 2 3 4] user=> (vec a) [1 2 3 4]
(defn aclone
"Returns a clone of the Java array. Works on arrays of known
types."
{:inline (fn [a] `(. clojure.lang.RT (aclone ~a)))
:added "1.0"}
[array] (. clojure.lang.RT (aclone array)))
Comments top
No comments for aclone. Log in to add a comment.