pop!(collection)
pop!(collection) -> item
Remove the last item in collection
and return it.
julia> A=[1, 2, 3, 4, 5, 6]
6-element Array{Int64,1}:
1
2
3
4
5
6
julia> pop!(A)
6
julia> A
5-element Array{Int64,1}:
1
2
3
4
5
Examples
julia> b = [3, 4, 5]
pop!(b)
5
julia> a = [1, 2]
push!(a, 3)
pop!(a)
3
julia> foo = [1,2,3];
julia> pop!(foo)
3
julia> foo
2-element Array{Int64,1}:
1
2
Associative collections
julia> dict = {"A"=>1, "B"=>2, "C"=>3, "D"=>4};
julia> pop!(dict,"A")
1
julia> pop!(dict,"E")
ERROR: key not found: "E"
in pop! at dict.jl:646
julia> pop!(dict,"E",42)
42
julia> dict
Dict{Any,Any} with 3 entries:
"B" => 2
"C" => 3
"D" => 4
See Also
append!, delete!, deleteat!, empty!, endof, filter, filter!, gc, get!, getkey, haskey, insert!, isempty, keys, map, map!, merge, merge!, pop!, prepend!, push!, reduce, resize!, shift!, splice!, unshift!, values,User Contributed Notes
Add a Note
The format of note supported is markdown, use triple backtick to start and end a code block.