public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
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
dhh (author)
Fri Nov 21 00:06:46 -0800 2008
commit  e50530ca3ab5db53ebc74314c54b62b91b932389
tree    9c7c2425229d7f3130e94f52ff36f57f7f79c185
parent  1d4554d766dbf8391689d91b4b88766757051c68
...
70
71
72
73
 
74
75
76
...
70
71
72
 
73
74
75
76
0
@@ -70,7 +70,7 @@
0
 
0
 * Added TimeZone #=~, to support matching zones by regex in time_zone_select. #195 [Ernie Miller]
0
 
0
-* Added Array#second through Array#tenth as aliases for Array#[1] through Array#[9] [DHH]
0
+* Added Array#second through Array#fifth as aliases for Array#[1] through Array#[4] + Array#forty_two as alias for Array[41] [DHH]
0
 
0
 * Added test/do declaration style testing to ActiveSupport::TestCase [DHH via Jay Fields]
0
 
...
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
 
 
 
69
70
71
...
43
44
45
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
46
47
48
49
50
51
0
@@ -43,29 +43,9 @@ module ActiveSupport #:nodoc:
0
           self[4]
0
         end
0
 
0
-        # Equal to <tt>self[5]</tt>.
0
-        def sixth
0
-          self[5]
0
-        end
0
-
0
-        # Equal to <tt>self[6]</tt>.
0
-        def seventh
0
-          self[6]
0
-        end
0
-
0
-        # Equal to <tt>self[7]</tt>.
0
-        def eighth
0
-          self[7]
0
-        end
0
-
0
-        # Equal to <tt>self[8]</tt>.
0
-        def ninth
0
-          self[8]
0
-        end
0
-
0
-        # Equal to <tt>self[9]</tt>.
0
-        def tenth
0
-          self[9]
0
+        # Equal to <tt>self[41]</tt>. Also known as accessing "the reddit".
0
+        def forty_two
0
+          self[41]
0
         end
0
       end
0
     end
...
15
16
17
18
 
19
20
21
22
23
24
25
26
27
28
 
29
30
31
...
15
16
17
 
18
19
20
21
22
23
 
 
 
 
 
24
25
26
27
0
@@ -15,17 +15,13 @@ class ArrayExtAccessTests < Test::Unit::TestCase
0
   end
0
   
0
   def test_second_through_tenth
0
-    array = (1..10).to_a
0
+    array = (1..42).to_a
0
     
0
     assert_equal array[1], array.second
0
     assert_equal array[2], array.third
0
     assert_equal array[3], array.fourth
0
     assert_equal array[4], array.fifth
0
-    assert_equal array[5], array.sixth
0
-    assert_equal array[6], array.seventh
0
-    assert_equal array[7], array.eighth
0
-    assert_equal array[8], array.ninth
0
-    assert_equal array[9], array.tenth
0
+    assert_equal array[41], array.fourty_two
0
   end
0
 end
0
 

Comments

kerryb Fri Nov 21 01:11:28 -0800 2008

Did you forget to run the test after correcting fourty_two to forty_second? ;-)

matthewrudy Fri Nov 21 03:17:38 -0800 2008

great, I’ve been waiting for this for ages.

tilsammans Fri Nov 21 03:25:36 -0800 2008

I am sure I am not getting this.

radar Fri Nov 21 04:06:23 -0800 2008

This should be Array#forty_second

adkron Fri Nov 21 04:33:47 -0800 2008

Ok, ok. This is funny. Thanks for reducing the overhead from your previous version.

henrik Fri Nov 21 04:38:34 -0800 2008
jameskilton Fri Nov 21 06:30:13 -0800 2008

Awesome, though now we’re missing Array#six and Array#nine.

blaix Fri Nov 21 07:31:19 -0800 2008

Great, now I’ll have to alias_method_chain this to forty_second…

nel Fri Nov 21 11:14:35 -0800 2008

Don’t need Array#thirty_seven too ?

charlieok Sun Nov 23 02:38:32 -0800 2008

Um, shouldn’t test_second_through_tenth be renamed to test_second_through_fifth?

pandemix Tue Nov 25 13:18:40 -0800 2008

Does your test succeed? The method is misspelled, using a ‘u’ where no ‘u’ should be.

Cute, tho’. Nice tip o’ the hat to the late Mr. Adams. Just started re-reading those books. What about 23, 37, and all those other important numbers? ;)

BTW, who uses ‘fourth’ or even ‘third’? (‘fifth’ is right out)

#first makes a lot of sense, #last is useful…