From 62fd46ad6340f15a33d47d4182013c5ca42835e0 Mon Sep 17 00:00:00 2001 From: Santosh Wadghule Date: Fri, 16 Jan 2015 22:44:45 +0530 Subject: A little performance improvement using 'take' method over 'first' --- activesupport/lib/active_support/core_ext/array/access.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activesupport/lib/active_support') diff --git a/activesupport/lib/active_support/core_ext/array/access.rb b/activesupport/lib/active_support/core_ext/array/access.rb index 45b89d2705..ca66d806ef 100644 --- a/activesupport/lib/active_support/core_ext/array/access.rb +++ b/activesupport/lib/active_support/core_ext/array/access.rb @@ -21,7 +21,7 @@ class Array # %w( a b c ).to(-10) # => [] def to(position) if position >= 0 - first position + 1 + take position + 1 else self[0..position] end -- cgit v1.2.3