aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorKuldeep Aggarwal <kd.engineer@yahoo.co.in>2014-05-23 21:32:52 +0530
committerKuldeep Aggarwal <kd.engineer@yahoo.co.in>2014-05-23 21:32:52 +0530
commit0e9401733c55e3ca43e48ad2b9b60520ef57387f (patch)
tree920b4180720330ceca6d9f50fbd4a7dad74bc28c /activesupport/lib
parent2fdddcee6fbc9f588285d8e5670303ffb533f170 (diff)
downloadrails-0e9401733c55e3ca43e48ad2b9b60520ef57387f.tar.gz
rails-0e9401733c55e3ca43e48ad2b9b60520ef57387f.tar.bz2
rails-0e9401733c55e3ca43e48ad2b9b60520ef57387f.zip
revert 96525d63
`Array#to` is working for negative position
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/array/access.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/access.rb b/activesupport/lib/active_support/core_ext/array/access.rb
index 67f58bc0fe..3f65f97524 100644
--- a/activesupport/lib/active_support/core_ext/array/access.rb
+++ b/activesupport/lib/active_support/core_ext/array/access.rb
@@ -15,8 +15,10 @@ class Array
# %w( a b c d ).to(2) # => ["a", "b", "c"]
# %w( a b c d ).to(10) # => ["a", "b", "c", "d"]
# %w().to(0) # => []
+ # %w( a b c d ).to(-2) # => ["a", "b", "c"]
+ # %w( a b c ).to(-10) # => []
def to(position)
- first position + 1
+ self[0..position]
end
# Equal to <tt>self[1]</tt>.