Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Force push! and unshift! to need at least one item #10400

Merged
merged 1 commit into from
Mar 5, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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