Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Rename Array#tail to Array#butfirst to avoid confusion with list term…

…inology
  • Loading branch information...
commit 99a24161d8dd90cd40713feab9e50a5a3b5995d7 1 parent 3f28be2
@bbatsov authored
View
2  README.md
@@ -22,8 +22,8 @@ Or install it yourself as:
## Extensions
* [Array](http://rdoc.info/github/bbatsov/powerpack/Array)
+ * [#butfirst](http://rdoc.info/github/bbatsov/powerpack/Array#butfirst-instance_method)
* [#butlast](http://rdoc.info/github/bbatsov/powerpack/Array#butlast-instance_method)
- * [#tail](http://rdoc.info/github/bbatsov/powerpack/Array#tail-instance_method)
* [Enumerable](http://rdoc.info/github/bbatsov/powerpack/Enumerable)
* [#average](http://rdoc.info/github/bbatsov/powerpack/Enumerable#average-instance_method)
* [#drop_last](http://rdoc.info/github/bbatsov/powerpack/Enumerable#drop_last-instance_method)
View
2  lib/powerpack/array.rb
@@ -1,2 +1,2 @@
require_relative 'array/butlast'
-require_relative 'array/tail'
+require_relative 'array/butfirst'
View
8 lib/powerpack/array/tail.rb → lib/powerpack/array/butfirst.rb
@@ -1,4 +1,4 @@
-unless Array.method_defined? :tail
+unless Array.method_defined? :butfirst
class Array
# Returns a new array rejecting the current one's first element.
#
@@ -6,9 +6,9 @@ class Array
# array is empty
#
# @example
- # [1, 2, 3].tail #=> [2, 3]
- # [].tail #=> nil
- def tail
+ # [1, 2, 3].butfirst #=> [2, 3]
+ # [].butfirst #=> nil
+ def butfirst
self[1..-1]
end
end
View
6 spec/powerpack/array/tail_spec.rb → spec/powerpack/array/butfirst_spec.rb
@@ -1,11 +1,11 @@
require 'spec_helper'
-describe 'Array#tail' do
+describe 'Array#butfirst' do
it 'returns an array without the first element' do
- expect([1, 2, 3].tail).to eq([2, 3])
+ expect([1, 2, 3].butfirst).to eq([2, 3])
end
it 'returns nil for empty lists' do
- expect([].tail).to be_nil
+ expect([].butfirst).to be_nil
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.