Skip to content

Commit

Permalink
Merge pull request JuliaLang#10400 from JuliaLang/jcb/pushchg
Browse files Browse the repository at this point in the history
Force push! and unshift! to need at least one item
  • Loading branch information
ivarne committed Mar 5, 2015
2 parents ded4bd4 + 8df4704 commit 27b6bbf
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ Library improvements
Deprecated or removed
---------------------

* `push!(A)` has been deprecated, use `append!` instead of splatting arguments to `push!` ([#10400]).

* `names` for composite datatypes has been deprecated and
renamed to `fieldnames` ([#10332]).

Expand Down
2 changes: 0 additions & 2 deletions base/abstractarray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -1453,10 +1453,8 @@ end

# multi-item push!, unshift! (built on top of type-specific 1-item version)
# (note: must not cause a dispatch loop when 1-item case is not defined)
push!(A) = A
push!(A, a, b) = push!(push!(A, a), b)
push!(A, a, b, c...) = push!(push!(A, a, b), c...)
unshift!(A) = A
unshift!(A, a, b) = unshift!(unshift!(A, b), a)
unshift!(A, a, b, c...) = unshift!(unshift!(A, c...), a, b)

Expand Down
5 changes: 5 additions & 0 deletions base/deprecated.jl
Original file line number Diff line number Diff line change
Expand Up @@ -307,3 +307,8 @@ end

@deprecate names(t::DataType) fieldnames(t)
@deprecate names(v) fieldnames(v)

function push!(A)
depwarn("push!(A) has been deprecated", :push!)
A
end
4 changes: 2 additions & 2 deletions doc/stdlib/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,7 @@ Dequeues

.. function:: push!(collection, items...) -> collection

Insert zero or more ``items`` at the end of ``collection``.
Insert one or more ``items`` at the end of ``collection``.

.. doctest::

Expand Down Expand Up @@ -846,7 +846,7 @@ Dequeues

.. function:: unshift!(collection, items...) -> collection

Insert zero or more ``items`` at the beginning of ``collection``.
Insert one or more ``items`` at the beginning of ``collection``.

.. doctest::

Expand Down

0 comments on commit 27b6bbf

Please sign in to comment.