From e50530ca3ab5db53ebc74314c54b62b91b932389 Mon Sep 17 00:00:00 2001
From: David Heinemeier Hansson <david@loudthinking.com>
Date: Fri, 21 Nov 2008 09:06:46 +0100
Subject: Reduced the number of literal aliases to the range that has actually
 seen personal use. With the massive savings in overhead, I was able to fit
 Array#forty_two

---
 activesupport/CHANGELOG                            |  2 +-
 .../lib/active_support/core_ext/array/access.rb    | 26 +++-------------------
 activesupport/test/core_ext/array_ext_test.rb      |  8 ++-----
 3 files changed, 6 insertions(+), 30 deletions(-)

(limited to 'activesupport')

diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index 0717d344d7..d0895bb709 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -70,7 +70,7 @@
 
 * Added TimeZone #=~, to support matching zones by regex in time_zone_select. #195 [Ernie Miller]
 
-* Added Array#second through Array#tenth as aliases for Array#[1] through Array#[9] [DHH]
+* Added Array#second through Array#fifth as aliases for Array#[1] through Array#[4] + Array#forty_two as alias for Array[41] [DHH]
 
 * Added test/do declaration style testing to ActiveSupport::TestCase [DHH via Jay Fields]
 
diff --git a/activesupport/lib/active_support/core_ext/array/access.rb b/activesupport/lib/active_support/core_ext/array/access.rb
index a3b2a54c7d..6de338bfcc 100644
--- a/activesupport/lib/active_support/core_ext/array/access.rb
+++ b/activesupport/lib/active_support/core_ext/array/access.rb
@@ -43,29 +43,9 @@ module ActiveSupport #:nodoc:
           self[4]
         end
 
-        # Equal to <tt>self[5]</tt>.
-        def sixth
-          self[5]
-        end
-
-        # Equal to <tt>self[6]</tt>.
-        def seventh
-          self[6]
-        end
-
-        # Equal to <tt>self[7]</tt>.
-        def eighth
-          self[7]
-        end
-
-        # Equal to <tt>self[8]</tt>.
-        def ninth
-          self[8]
-        end
-
-        # Equal to <tt>self[9]</tt>.
-        def tenth
-          self[9]
+        # Equal to <tt>self[41]</tt>. Also known as accessing "the reddit".
+        def forty_two
+          self[41]
         end
       end
     end
diff --git a/activesupport/test/core_ext/array_ext_test.rb b/activesupport/test/core_ext/array_ext_test.rb
index 62a1f61d53..32cab2724b 100644
--- a/activesupport/test/core_ext/array_ext_test.rb
+++ b/activesupport/test/core_ext/array_ext_test.rb
@@ -15,17 +15,13 @@ class ArrayExtAccessTests < Test::Unit::TestCase
   end
   
   def test_second_through_tenth
-    array = (1..10).to_a
+    array = (1..42).to_a
     
     assert_equal array[1], array.second
     assert_equal array[2], array.third
     assert_equal array[3], array.fourth
     assert_equal array[4], array.fifth
-    assert_equal array[5], array.sixth
-    assert_equal array[6], array.seventh
-    assert_equal array[7], array.eighth
-    assert_equal array[8], array.ninth
-    assert_equal array[9], array.tenth
+    assert_equal array[41], array.fourty_two
   end
 end
 
-- 
cgit v1.2.3