• (pop! coll)
Alpha - subject to change.
Removes the last item from a transient vector. If
the collection is empty, throws an exception. Returns coll

1 Example top

  • ;; Note how we always use the return value of pop! in these examples
    ;; for all future modifications, rather than (incorrectly) ignoring the return
    ;; value and continuing to modify the original transient set.  See examples for
    ;; assoc! and dissoc! for more discussion and examples of this.
    
    user=> (def foo (transient [1 2 3]))
    #'user/foo
    user=> (count foo)
    3
    user=> (def foo (pop! foo))
    #'user/foo
    user=> foo
    #<TransientVector clojure.lang.PersistentVector$TransientVector@1638fff7>
    user=> (count foo)
    2
    user=> (def foo (pop! foo))
    #'user/foo
    user=> (count foo)
    1
    user=> (def foo (persistent! foo))
    #'user/foo
    user=> (count foo)
    1
    user=> foo
    [1]
    
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:2976 top

(defn pop!
  "Alpha - subject to change.
  Removes the last item from a transient vector. If
  the collection is empty, throws an exception. Returns coll"
  {:added "1.1"
   :static true}
  [^clojure.lang.ITransientVector coll] 
  (.pop coll))
Vars in clojure.core/pop!:
Used in 0 other vars

Comments top

No comments for pop!. Log in to add a comment.