• (aget array idx)
  • (aget array idx & idxs)
Returns the value at the index/indices. Works on Java arrays of all
types.

1 Example top

  • ;; create two arrays
    user=> (def a1 (double-array '(1.0 2.0 3.0 4.0)))
    #'user/a1
    user=> (def a2 (int-array '(9 8 7 6)))
    #'user/a2
    
    ;; get an item by index
    user=> (aget a1 2)
    3.0
    user=> (aget a2 3)
    6
    
    ;; 2d array and 2 indicies
    user=> (def a3 (make-array Integer/TYPE 100 100))
    #'user/a3
    user=> (aget a3 23 42)
    0
    
Log in to add / edit an example.

See Also top

  • 0
    clojure.core/aclone

    Returns a clone of the Java array. Works on arrays of known types.

  • 0
    clojure.core/get

    Returns the value mapped to key, not-found or nil if key not present.

  • 0
    clojure.core/nth

    Returns the value at the index. get returns nil if index out of bou

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:3450 top

(defn aget
  "Returns the value at the index/indices. Works on Java arrays of all
  types."
  {:inline (fn [a i] `(. clojure.lang.RT (aget ~a (int ~i))))
   :inline-arities #{2}
   :added "1.0"}
  ([array idx]
   (clojure.lang.Reflector/prepRet (.getComponentType (class array)) (. Array (get array idx))))
  ([array idx & idxs]
   (apply aget (aget array idx) idxs)))
Vars in clojure.core/aget:
Used in 0 other vars

Comments top

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