aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJared McFarland <jared.online@gmail.com>2011-04-26 14:46:52 -0700
committerJared McFarland <jared.online@gmail.com>2011-04-26 14:46:52 -0700
commit74634d452b3087575fe7b912da9827021aed4a70 (patch)
tree6a75ceb552ca9a6b66eb5002562222da710f4b9c /activesupport/lib
parent4ce14fb0809ea8d636be0a1790fa38eafe64a46f (diff)
downloadrails-74634d452b3087575fe7b912da9827021aed4a70.tar.gz
rails-74634d452b3087575fe7b912da9827021aed4a70.tar.bz2
rails-74634d452b3087575fe7b912da9827021aed4a70.zip
fixing Array#from to return consistent results
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/core_ext/array/access.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/activesupport/lib/active_support/core_ext/array/access.rb b/activesupport/lib/active_support/core_ext/array/access.rb
index c69a015f12..a2086fa3e5 100644
--- a/activesupport/lib/active_support/core_ext/array/access.rb
+++ b/activesupport/lib/active_support/core_ext/array/access.rb
@@ -3,10 +3,10 @@ class Array
#
# %w( a b c d ).from(0) # => %w( a b c d )
# %w( a b c d ).from(2) # => %w( c d )
- # %w( a b c d ).from(10) # => nil
+ # %w( a b c d ).from(10) # => %w()
# %w().from(0) # => %w()
def from(position)
- self[position..-1]
+ position > length ? [] : self[position..-1]
end
# Returns the beginning of the array up to +position+.