ClojureDocs

导航

命名空间

pop!

clojure.core

现已推出 1.1 (源代码)
  • (pop! coll)
Removes the last item from a transient vector. If
the collection is empty, throws an exception. Returns coll
1 Example
;; 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.
;; Also see one example for conj! that contains a detailed example
;; of a wrong result that can occur if you do not use its return value.

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]
See Also

When applied to a transient map, adds mapping of key(s) to val(s). When applied to a transient vec...

Added by jafingerhut

Returns a transient map that doesn't contain a mapping for key(s).

Added by jafingerhut

Adds x to the transient collection, and return coll. The 'addition' may happen at different 'place...

Added by jafingerhut
0 Notes
No notes for pop!