Permalink
Browse files

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
  • Loading branch information...
dhh committed Nov 21, 2008
1 parent 1d4554d commit e50530ca3ab5db53ebc74314c54b62b91b932389
View
@@ -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]
@@ -43,29 +43,9 @@ def fifth
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
@@ -15,17 +15,13 @@ def test_to
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

13 comments on commit e50530c

@kerryb

This comment has been minimized.

Show comment
Hide comment
@kerryb

kerryb Nov 21, 2008

Contributor

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

Contributor

kerryb replied Nov 21, 2008

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

@matthewrudy

This comment has been minimized.

Show comment
Hide comment
@matthewrudy

matthewrudy Nov 21, 2008

Contributor

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

Contributor

matthewrudy replied Nov 21, 2008

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

@tilsammans

This comment has been minimized.

Show comment
Hide comment
@tilsammans

tilsammans Nov 21, 2008

Contributor

I am sure I am not getting this.

Contributor

tilsammans replied Nov 21, 2008

I am sure I am not getting this.

@radar

This comment has been minimized.

Show comment
Hide comment
@radar

radar Nov 21, 2008

Contributor

This should be Array#forty_second

Contributor

radar replied Nov 21, 2008

This should be Array#forty_second

@adkron

This comment has been minimized.

Show comment
Hide comment
@adkron

adkron Nov 21, 2008

Contributor

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

Contributor

adkron replied Nov 21, 2008

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

@henrik

This comment has been minimized.

Show comment
Hide comment
@henrik

henrik Nov 21, 2008

Contributor

tilsammans: http://en.wikipedia.org/wiki/Notable_phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy#Answer_to_Life.2C_the_Universe_and_Everything_.2842.29

Contributor

henrik replied Nov 21, 2008

tilsammans: http://en.wikipedia.org/wiki/Notable_phrases_from_The_Hitchhiker%27s_Guide_to_the_Galaxy#Answer_to_Life.2C_the_Universe_and_Everything_.2842.29

@jasonroelofs

This comment has been minimized.

Show comment
Hide comment
@jasonroelofs

jasonroelofs Nov 21, 2008

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

jasonroelofs replied Nov 21, 2008

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

@blaix

This comment has been minimized.

Show comment
Hide comment
@blaix

blaix Nov 21, 2008

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

blaix replied Nov 21, 2008

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

@nel

This comment has been minimized.

Show comment
Hide comment
@nel

nel Nov 21, 2008

Don’t need Array#thirty_seven too ?

nel replied Nov 21, 2008

Don’t need Array#thirty_seven too ?

@charlieok

This comment has been minimized.

Show comment
Hide comment
@charlieok

charlieok Nov 23, 2008

Um, shouldn’t test_second_through_tenth be renamed to test_second_through_fifth?

charlieok replied Nov 23, 2008

Um, shouldn’t test_second_through_tenth be renamed to test_second_through_fifth?

@pandemix

This comment has been minimized.

Show comment
Hide comment
@pandemix

pandemix Nov 25, 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)

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

pandemix replied Nov 25, 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)

  1. first makes a lot of sense, #last is useful…
@zenhob

This comment has been minimized.

Show comment
Hide comment
@zenhob

zenhob Jul 23, 2009

@radar is right, this should be Array#forty_second.

zenhob replied Jul 23, 2009

@radar is right, this should be Array#forty_second.

@deeTEEcee

This comment has been minimized.

Show comment
Hide comment
@deeTEEcee

deeTEEcee replied Jul 7, 2016

dafuq?

Please sign in to comment.