From 3920d64479c8763e1f0a64db872e5f072268cda9 Mon Sep 17 00:00:00 2001 From: Kuldeep Aggarwal Date: Fri, 23 May 2014 20:47:21 +0530 Subject: add test cases for negative position in Array#from --- activesupport/lib/active_support/core_ext/array/access.rb | 2 ++ 1 file changed, 2 insertions(+) (limited to 'activesupport/lib') diff --git a/activesupport/lib/active_support/core_ext/array/access.rb b/activesupport/lib/active_support/core_ext/array/access.rb index 67f58bc0fe..d0791a161f 100644 --- a/activesupport/lib/active_support/core_ext/array/access.rb +++ b/activesupport/lib/active_support/core_ext/array/access.rb @@ -5,6 +5,8 @@ class Array # %w( a b c d ).from(2) # => ["c", "d"] # %w( a b c d ).from(10) # => [] # %w().from(0) # => [] + # %w( a b c d ).from(-2) # => ["c", "d"] + # %w( a b c ).from(-10) # => [] def from(position) self[position, length] || [] end -- cgit v1.2.3