1.3.0 permalink Arrow_down_16x16
  • (aset array idx val)
  • (aset array idx idx2 & idxv)
Sets the value at the index/indices. Works on Java arrays of
reference types. Returns val.

1 Example top

  • user=> (def my-array (into-array Integer/TYPE [1 2 3]))
    #'user/my-array
    
    user=> (aset my-array 1 10) ; Set the element with index 1 to 10
    10
    
    user=> (into [] my-array)
    [1 10 3]
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:3461 top

(defn aset
  "Sets the value at the index/indices. Works on Java arrays of
  reference types. Returns val."
  {:inline (fn [a i v] `(. clojure.lang.RT (aset ~a (int ~i) ~v)))
   :inline-arities #{3}
   :added "1.0"}
  ([array idx val]
   (. Array (set array idx val))
   val)
  ([array idx idx2 & idxv]
   (apply aset (aget array idx) idx2 idxv)))
Vars in clojure.core/aset:
Used in 0 other vars

Comments top

No comments for aset. Log in to add a comment.