Skip to content
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#fourty_two
  • Loading branch information...
dhh committed Nov 21, 2008
1 parent 5b72c9b commit 9d8cc60ec3845fa3e6f9292a65b119fe4f619f7e
@@ -64,7 +64,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#fourty_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 fourty_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

39 comments on commit 9d8cc60

@alloy

This comment has been minimized.

Copy link
Contributor

alloy replied Nov 21, 2008

Hehe, nice. I wonder what kind of thread this will spawn :-)

@ghost

This comment has been minimized.

Copy link

ghost replied Nov 21, 2008

Shouldn’t this be called fourty_second?

@maseb

This comment has been minimized.

Copy link

maseb replied Nov 21, 2008

Lordy.

@devpopol

This comment has been minimized.

Copy link

devpopol replied Nov 21, 2008

lol!

@ghost

This comment has been minimized.

Copy link

ghost replied Nov 21, 2008

This is a useful addition. Could you also provide Array#[π] please as I would like to access the 4.14159th element of my arrays but I can’t find a way to. Many thanks

@datra

This comment has been minimized.

Copy link

datra replied Nov 21, 2008

Danish humor :)

@wtn

This comment has been minimized.

Copy link

wtn replied Nov 21, 2008

You probably want to change it to Array#forty_two

@ledermann

This comment has been minimized.

Copy link
Contributor

ledermann replied Nov 21, 2008

I wish I could unsubscribe from specific github comment thread…

@devpopol

This comment has been minimized.

Copy link

devpopol replied Nov 21, 2008

http://www.reddit.com/r/programming/comments/7erjo/hot_on_the_heels_of_arrayfourth_rails_now_ships/

someone got to submit the link first.. heh..

@anildigital

This comment has been minimized.

Copy link
Contributor

anildigital replied Nov 21, 2008

lol

@carllerche

This comment has been minimized.

Copy link
Contributor

carllerche replied Nov 21, 2008

I’d like to propose the following patch:

class Fixnum

alias mult_before_the_answer * def *(other) return 42 if self == 6 && other == 8 mult_before_the_answer(other) end

end

@rmoriz

This comment has been minimized.

Copy link

rmoriz replied Nov 21, 2008

April 1st already? 8→

@hojberg

This comment has been minimized.

Copy link

hojberg replied Nov 21, 2008

rofl …. <3

@elia

This comment has been minimized.

Copy link
Contributor

elia replied Nov 21, 2008

Please don’t touch second and third d2h! I already use (and love) them in a production app!!!

Best people always go first… :‘(
I miss you all sixth..tenth
And you, fourtytwo, don’t feel guilty_

@lackac

This comment has been minimized.

Copy link
Contributor

lackac replied Nov 21, 2008

Nice, now if we could just find the right array to send this method to…

@monde

This comment has been minimized.

Copy link
Contributor

monde replied Nov 21, 2008

does that constitute an easter egg or just part of an easter egg shell?

@Roman2K

This comment has been minimized.

Copy link

Roman2K replied Nov 21, 2008

This commit is a joke, right?

@rmoriz

This comment has been minimized.

Copy link

rmoriz replied Nov 21, 2008

I think the “other” people’s republic of Counting (Province of Numbers) rates forty_two as offensive besides all ISO norms: Danger!

@datra

This comment has been minimized.

Copy link

datra replied Nov 21, 2008

This is why you don’t want to run edge rails.

@unimatrixZxero

This comment has been minimized.

Copy link

unimatrixZxero replied Nov 21, 2008

Are the people complaining about Array#forty_two not aware of the cultural reference?

@neilh

This comment has been minimized.

Copy link

neilh replied Nov 21, 2008

if not, why not

@augustl

This comment has been minimized.

Copy link

augustl replied Nov 21, 2008

Thanks, David! Finally Rails scales.

@vesan

This comment has been minimized.

Copy link
Contributor

vesan replied Nov 21, 2008

lol @ rmoriz

@littlestarling

This comment has been minimized.

Copy link

littlestarling replied Nov 21, 2008

What do you get if you multply six by nine? :)

@radar

This comment has been minimized.

Copy link
Contributor

radar replied Nov 21, 2008

@littlestarling: 54.

@cpjolicoeur

This comment has been minimized.

Copy link

cpjolicoeur replied Nov 21, 2008

brilliant

@georgi

This comment has been minimized.

Copy link

georgi replied Nov 21, 2008

I don’t like the syntax. For accessing “the Reddit” I’d rather prefer the explicit way:

```
Reddit::Thread.start do
loop do
Reddit::Comment.create
sleep 1
end
end
```

@dhh

This comment has been minimized.

Copy link
Member Author

dhh replied Nov 21, 2008

Please don’t spoil the joke of revealing the reference :).

Also, this will ship in Rails 2.2. Having this much power should not be available only to edge users.

@scottymac

This comment has been minimized.

Copy link

scottymac replied Nov 21, 2008

Yeah, it should be “forty”; one of a multitude of silly linguistic developments in English that makes no sense. I shudder to think what learning English as a second language must be like…

@sw0rdfish

This comment has been minimized.

Copy link

sw0rdfish replied Nov 21, 2008

WOOT! Finally!

Brilliant David! Love it!

@dhh

This comment has been minimized.

Copy link
Member Author

dhh replied Nov 21, 2008

It was changed to forty_two in a later commit. And yes, scottymac, it’s a strange exception.

@virtualmice

This comment has been minimized.

Copy link

virtualmice replied Nov 21, 2008

Don’t panic !

(or should I panic ?)

@spiceee

This comment has been minimized.

Copy link

spiceee replied Nov 21, 2008

@scottymac languages thrive on exceptions. English is possibly the easiest to learn as second language.

@ncr

This comment has been minimized.

Copy link
Contributor

ncr replied Nov 22, 2008

This is Good.

@ncr

This comment has been minimized.

Copy link
Contributor

ncr replied Nov 22, 2008

As in Good vs. Evil.

@ianwhite

This comment has been minimized.

Copy link
Contributor

ianwhite replied Nov 22, 2008

def six_times_nine_if_i_had_thirteen_fingers
  self[41]
end
@littlestarling

This comment has been minimized.

Copy link

littlestarling replied Nov 25, 2008

@Radar: see “Answer to Life, the Universe and Everything”
http://tinyurl.com/6kbzkw

@josevalim

This comment has been minimized.

Copy link
Contributor

josevalim replied Jan 3, 2009

Maybe Merb guys will fix it now! =P

@Aupajo

This comment has been minimized.

Copy link

Aupajo replied Jan 5, 2009

+1 @ianwhite

Please sign in to comment.
You can’t perform that action at this time.