Skip to content

Commit

Permalink
Merge pull request #28638 from bogdanvlviv/prepend_and_append_in_ruby
Browse files Browse the repository at this point in the history
Prevent aliases Array#append and Array#prepend
  • Loading branch information
kaspth committed Apr 15, 2017
2 parents c8a9ac0 + 49a4637 commit 1e0d842
Showing 1 changed file with 2 additions and 2 deletions.
@@ -1,7 +1,7 @@
class Array
# The human way of thinking about adding stuff to the end of a list is with append.
alias_method :append, :<<
alias_method :append, :push unless [].respond_to?(:append)

# The human way of thinking about adding stuff to the beginning of a list is with prepend.
alias_method :prepend, :unshift
alias_method :prepend, :unshift unless [].respond_to?(:prepend)
end

0 comments on commit 1e0d842

Please sign in to comment.