Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 9d8cc60ec3845fa3e6f9292a65b119fe4f619f7e 1 parent 5b72c9b
@dhh dhh authored
View
2  activesupport/CHANGELOG
@@ -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]
View
26 activesupport/lib/active_support/core_ext/array/access.rb
@@ -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
View
8 activesupport/test/core_ext/array_ext_test.rb
@@ -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

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

@eet-nu

Shouldn’t this be called fourty_second?

@maseb

Lordy.

@devpopol

lol!

@vlc

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

Danish humor :)

@wtn

You probably want to change it to Array#forty_two

@ledermann

I wish I could unsubscribe from specific github comment thread…

@devpopol

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..

@carllerche
Collaborator

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

April 1st already? 8→

@hojberg

rofl …. <3

@elia

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

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

@monde

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

@Roman2K

This commit is a joke, right?

@rmoriz

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

@datra

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

@unimatrixZxero

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

@neilh

if not, why not

@augustl

Thanks, David! Finally Rails scales.

@vesan

lol @ rmoriz

@littlestarling

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

@radar

@littlestarling: 54.

@cpjolicoeur

brilliant

@georgi

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
Owner

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

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

WOOT! Finally!

Brilliant David! Love it!

@dhh
Owner

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

@virtualmice

Don’t panic !

(or should I panic ?)

@spiceee

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

@ncr

This is Good.

@ncr

As in Good vs. Evil.

@ianwhite
def six_times_nine_if_i_had_thirteen_fingers
  self[41]
end
@littlestarling

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

@josevalim
Owner

Maybe Merb guys will fix it now! =P

@Aupajo

+1 @ianwhite

Please sign in to comment.
Something went wrong with that request. Please try again.