Permalink
Browse files

Added Array#second through Array#tenth as aliases for Array#[1] throu…

…gh Array#[9] [DHH]
  • Loading branch information...
dhh committed Jun 17, 2008
1 parent 7650ff8 commit 22af62cf486721ee2e45bb720c42ac2f4121faf4
View
@@ -1,5 +1,7 @@
*Edge*
* Added Array#second through Array#tenth as aliases for Array#[1] through Array#[9] [DHH]
* Added test/do declaration style testing to ActiveSupport::TestCase [DHH via Jay Fields]
* Added Object#present? which is equivalent to !Object#blank? [DHH]
@@ -20,6 +20,51 @@ def from(position)
def to(position)
self[0..position]
end
# Equal to self[1]

This comment has been minimized.

Show comment
Hide comment
@mikehale

mikehale Nov 21, 2008

What’s with the redundant comments?

@mikehale

mikehale Nov 21, 2008

What’s with the redundant comments?

This comment has been minimized.

Show comment
Hide comment
@henrik

henrik Nov 21, 2008

Contributor

mikehale: The redundant comments are likely for RDoc.

@henrik

henrik Nov 21, 2008

Contributor

mikehale: The redundant comments are likely for RDoc.

def second
self[1]
end
# Equal to self[2]
def third
self[2]
end
# Equal to self[3]
def fourth
self[3]
end
# Equal to self[4]
def fifth
self[4]
end
# Equal to self[5]
def sixth
self[5]
end
# Equal to self[6]
def seventh
self[6]
end
# Equal to self[7]
def eighth
self[7]
end
# Equal to self[8]
def ninth
self[8]
end
# Equal to self[9]
def tenth
self[9]
end
end
end
end
@@ -13,6 +13,20 @@ def test_to
assert_equal %w( a b c ), %w( a b c d ).to(2)
assert_equal %w( a b c d ), %w( a b c d ).to(10)
end
def test_second_through_tenth
array = (1..10).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
end
end
class ArrayExtToParamTests < Test::Unit::TestCase

106 comments on commit 22af62c

@yaroslav

This comment has been minimized.

Show comment
Hide comment
@yaroslav

yaroslav Nov 18, 2008

Contributor

So many smart and helpful people in this thread, with original comments.

Contributor

yaroslav replied Nov 18, 2008

So many smart and helpful people in this thread, with original comments.

@NZKoz

This comment has been minimized.

Show comment
Hide comment
@NZKoz

NZKoz Nov 18, 2008

Member

Gee guys, your helpful attitude astounds me. Here’s an idea, don’t use the methods and they won’t bug you.

If you really think 10 methods equals bloat, you’d better go and remove every class and method in your application! Let me give you a quick head start:


 def entire_app(url)
  case url
  when "/hello_world.txt"
    "Hello WORLD!"
  end
 end

Member

NZKoz replied Nov 18, 2008

Gee guys, your helpful attitude astounds me. Here’s an idea, don’t use the methods and they won’t bug you.

If you really think 10 methods equals bloat, you’d better go and remove every class and method in your application! Let me give you a quick head start:


 def entire_app(url)
  case url
  when "/hello_world.txt"
    "Hello WORLD!"
  end
 end

@jinzhu

This comment has been minimized.

Show comment
Hide comment
@jinzhu

jinzhu Nov 18, 2008

10 useless methods,another 10 useless methods,another 10 useless methods ……

jinzhu replied Nov 18, 2008

10 useless methods,another 10 useless methods,another 10 useless methods ……

@peter

This comment has been minimized.

Show comment
Hide comment
@peter

peter Nov 18, 2008

+1 for this change

peter replied Nov 18, 2008

+1 for this change

@dhh

This comment has been minimized.

Show comment
Hide comment
@dhh

dhh Nov 18, 2008

Member

Haha. I’m honored by the attention of this commit! It reminds me of the good ol’ days where we debated whether pluralization was worth it. Or whether 1.second was good. Thanks for the memories ;).

This particular patch was born from the daily work I do administrating the applications at 37signals. A lot of the support work requires going into script/console and investigating various objects. In the console, I got sick of not being able to do people.second when I had a collection and knew I needed the second record. first and last was so nice and fluid, but if I needed second or third, I had to drop back to array access. Didn’t like that, so here you go.

Member

dhh replied Nov 18, 2008

Haha. I’m honored by the attention of this commit! It reminds me of the good ol’ days where we debated whether pluralization was worth it. Or whether 1.second was good. Thanks for the memories ;).

This particular patch was born from the daily work I do administrating the applications at 37signals. A lot of the support work requires going into script/console and investigating various objects. In the console, I got sick of not being able to do people.second when I had a collection and knew I needed the second record. first and last was so nice and fluid, but if I needed second or third, I had to drop back to array access. Didn’t like that, so here you go.

@DarkTatka

This comment has been minimized.

Show comment
Hide comment
@DarkTatka

DarkTatka Nov 18, 2008

i completely agree with this commit, 3 of 5 my applications end with this as extension anyway.

DarkTatka replied Nov 18, 2008

i completely agree with this commit, 3 of 5 my applications end with this as extension anyway.

@aizatto

This comment has been minimized.

Show comment
Hide comment
@aizatto

aizatto Nov 18, 2008

If you needed this so much, why not stuff this into ~/.irbrc instead? Then its global to all your consoles! Personally I think that would have been a much more appreciated solution rather than stuffing it into activesupport.

aizatto replied Nov 18, 2008

If you needed this so much, why not stuff this into ~/.irbrc instead? Then its global to all your consoles! Personally I think that would have been a much more appreciated solution rather than stuffing it into activesupport.

@jorrel

This comment has been minimized.

Show comment
Hide comment
@jorrel

jorrel Nov 18, 2008

I wanted ‘second’ when I’m iterating hashes. But ‘third’ to ‘tenth’ sugar doesn’t seem to taste that sweet. :)

jorrel replied Nov 18, 2008

I wanted ‘second’ when I’m iterating hashes. But ‘third’ to ‘tenth’ sugar doesn’t seem to taste that sweet. :)

@hgtesta

This comment has been minimized.

Show comment
Hide comment
@hgtesta

hgtesta Nov 18, 2008

+1 for this too. I always use Array#first and Array#last for arrays of size 2.

hgtesta replied Nov 18, 2008

+1 for this too. I always use Array#first and Array#last for arrays of size 2.

@radar

This comment has been minimized.

Show comment
Hide comment
@radar

radar Nov 18, 2008

Contributor

Doesn’t anyone else think that typing array1 is faster than typing array.second? Surely by now it’s become natural.

Contributor

radar replied Nov 18, 2008

Doesn’t anyone else think that typing array1 is faster than typing array.second? Surely by now it’s become natural.

@augustl

This comment has been minimized.

Show comment
Hide comment
@augustl

augustl Nov 18, 2008

I think the biggest problem with this is that when I see people.fifth in code, I won’t know what to do. Also, spotting people[4] is easier when skimming the code.

Then again, if the argument is that this was used a lot in console, it’s all good I guess.

augustl replied Nov 18, 2008

I think the biggest problem with this is that when I see people.fifth in code, I won’t know what to do. Also, spotting people[4] is easier when skimming the code.

Then again, if the argument is that this was used a lot in console, it’s all good I guess.

@dhh

This comment has been minimized.

Show comment
Hide comment
@dhh

dhh Nov 18, 2008

Member

I’ve actually also used it in code. It’s particularly useful for command parameters. Think ARGV.second, ARGV.third. But yeah, not something you’d use every day. My most common use is with the console.

Member

dhh replied Nov 18, 2008

I’ve actually also used it in code. It’s particularly useful for command parameters. Think ARGV.second, ARGV.third. But yeah, not something you’d use every day. My most common use is with the console.

@dhh

This comment has been minimized.

Show comment
Hide comment
@dhh

dhh Nov 18, 2008

Member

Radar, you could make the same argument against the built-in first and last. They have 0 and [-1] equivalents. But the English versions read nicer. Ruby is full of stuff that merely improves on readability. I love that about the language.

Member

dhh replied Nov 18, 2008

Radar, you could make the same argument against the built-in first and last. They have 0 and [-1] equivalents. But the English versions read nicer. Ruby is full of stuff that merely improves on readability. I love that about the language.

@georgi

This comment has been minimized.

Show comment
Hide comment
@georgi

georgi Nov 18, 2008

I guess, this is just a diss to all the LOC counters ;)

georgi replied Nov 18, 2008

I guess, this is just a diss to all the LOC counters ;)

@raganwald

This comment has been minimized.

Show comment
Hide comment
@raganwald

raganwald Nov 18, 2008

Contributor

Would anyone prefer methods like caddr?

Contributor

raganwald replied Nov 18, 2008

Would anyone prefer methods like caddr?

@NZKoz

This comment has been minimized.

Show comment
Hide comment
@NZKoz

NZKoz Nov 18, 2008

Member

perhaps cdaddaddr?

Member

NZKoz replied Nov 18, 2008

perhaps cdaddaddr?

@divineforest

This comment has been minimized.

Show comment
Hide comment
@divineforest

divineforest Nov 18, 2008

Contributor

Nice commit :). I suggest that those second…tenth methods to be added to ActiveRecord::Base as well so we could do just Person.second.

Contributor

divineforest replied Nov 18, 2008

Nice commit :). I suggest that those second…tenth methods to be added to ActiveRecord::Base as well so we could do just Person.second.

@bkerley

This comment has been minimized.

Show comment
Hide comment
@bkerley

bkerley Nov 18, 2008

@raganwald: http://github.com/ivey/carpark provides it

bkerley replied Nov 18, 2008

@raganwald: http://github.com/ivey/carpark provides it

@Peeja

This comment has been minimized.

Show comment
Hide comment
@Peeja

Peeja Nov 18, 2008

Contributor

Re: LOC:


        [:second, :third, :fourth, :fifth, :sixth, :seventh, :eighth, :ninth, :tenth].each_with_index do |name, i|
            define_method(name) { self[i+1] }
        end

Et voila.

Contributor

Peeja replied Nov 18, 2008

Re: LOC:


        [:second, :third, :fourth, :fifth, :sixth, :seventh, :eighth, :ninth, :tenth].each_with_index do |name, i|
            define_method(name) { self[i+1] }
        end

Et voila.

@Oshuma

This comment has been minimized.

Show comment
Hide comment
@Oshuma

Oshuma Nov 18, 2008

I think something like this should be included on a per-app basis, as opposed to being in core. How hard is it to just ‘cp array_stupid.rb ./lib’ for your projects?

-5 points for this, kthx.

Oshuma replied Nov 18, 2008

I think something like this should be included on a per-app basis, as opposed to being in core. How hard is it to just ‘cp array_stupid.rb ./lib’ for your projects?

-5 points for this, kthx.

@kris

This comment has been minimized.

Show comment
Hide comment
@kris

kris Nov 18, 2008

Commits like this push me closer to Merb.

kris replied Nov 18, 2008

Commits like this push me closer to Merb.

@ieure

This comment has been minimized.

Show comment
Hide comment
@ieure

ieure Nov 18, 2008

This is great, but could you please provide Japanese localization? It’s so much easier for me to use:

foo.二番目に, foo.第3, foo.第4

When I’m in the console instead of foo1, foo2…foo[N].

Thanks, I’d really appreciate it.

ieure replied Nov 18, 2008

This is great, but could you please provide Japanese localization? It’s so much easier for me to use:

foo.二番目に, foo.第3, foo.第4

When I’m in the console instead of foo1, foo2…foo[N].

Thanks, I’d really appreciate it.

@georgi

This comment has been minimized.

Show comment
Hide comment
@georgi

georgi Nov 18, 2008

@Peeja: your code will not show in the documentation.

georgi replied Nov 18, 2008

@Peeja: your code will not show in the documentation.

@maseb

This comment has been minimized.

Show comment
Hide comment
@maseb

maseb Nov 18, 2008

Or you could have some fancy-fun and alias :n(st/th) for 0 to your heart’s content. Then you get people.1st people.2nd… people.100th. If you’re feeling particularly courageous, you could toss the sucker in method_missing, and be able to do people.53485th.

maseb replied Nov 18, 2008

Or you could have some fancy-fun and alias :n(st/th) for 0 to your heart’s content. Then you get people.1st people.2nd… people.100th. If you’re feeling particularly courageous, you could toss the sucker in method_missing, and be able to do people.53485th.

@maseb

This comment has been minimized.

Show comment
Hide comment
@maseb

maseb Nov 18, 2008

Though I suppose that would cause confusion, since people expect “first” to be the “0th”. Well boo to that. Start at 1.

maseb replied Nov 18, 2008

Though I suppose that would cause confusion, since people expect “first” to be the “0th”. Well boo to that. Start at 1.

@maseb

This comment has been minimized.

Show comment
Hide comment
@maseb

maseb Nov 18, 2008

Or, I could learn Ruby, and realize that you can’t start a method with a number.

maseb replied Nov 18, 2008

Or, I could learn Ruby, and realize that you can’t start a method with a number.

@georgi

This comment has been minimized.

Show comment
Hide comment
@georgi

georgi Nov 18, 2008

Seriously I cant understand the console use case. Typing the brackets is for me way faster than typing a method name, even with tab completion.

georgi replied Nov 18, 2008

Seriously I cant understand the console use case. Typing the brackets is for me way faster than typing a method name, even with tab completion.

@dlisboa

This comment has been minimized.

Show comment
Hide comment
@dlisboa

dlisboa Nov 18, 2008

These methods are pointless. So are most method added for readability (Time.now instead of Time.new?). But I believe there are more important ways to spend our time, and more valuable discussions. Just leave it.

dlisboa replied Nov 18, 2008

These methods are pointless. So are most method added for readability (Time.now instead of Time.new?). But I believe there are more important ways to spend our time, and more valuable discussions. Just leave it.

@ericallam

This comment has been minimized.

Show comment
Hide comment
@ericallam

ericallam Nov 18, 2008

Contributor

Honestly the only arguments I can really see for being against this is the extra methods being in the Array#methods call, which I sometimes use in the console. But even then most of the time when I’m looking up a method I have a pretty good idea what its called so I usually end up doing #methods.grep /whatever/ anyways

Contributor

ericallam replied Nov 18, 2008

Honestly the only arguments I can really see for being against this is the extra methods being in the Array#methods call, which I sometimes use in the console. But even then most of the time when I’m looking up a method I have a pretty good idea what its called so I usually end up doing #methods.grep /whatever/ anyways

@brennandunn

This comment has been minimized.

Show comment
Hide comment
@brennandunn

brennandunn Nov 18, 2008

Contributor

More pointless bloat for the docs. What’s next, revamping #succ to make ‘first’.next # => ‘second’ ?

Contributor

brennandunn replied Nov 18, 2008

More pointless bloat for the docs. What’s next, revamping #succ to make ‘first’.next # => ‘second’ ?

@bkerley

This comment has been minimized.

Show comment
Hide comment
@bkerley

bkerley Nov 18, 2008

Can we get an alternate version for C users who think of arrays as a0 being the “zeroth,” a1 being “first,” etc.? I’d like the choice in my code.

bkerley replied Nov 18, 2008

Can we get an alternate version for C users who think of arrays as a0 being the “zeroth,” a1 being “first,” etc.? I’d like the choice in my code.

@Aupajo

This comment has been minimized.

Show comment
Hide comment
@Aupajo

Aupajo Nov 18, 2008

Sugar so sweet it makes my teeth ache.

Aupajo replied Nov 18, 2008

Sugar so sweet it makes my teeth ache.

@adkron

This comment has been minimized.

Show comment
Hide comment
@adkron

adkron Nov 18, 2008

Contributor

So what do things like this do to my load time, and my memory usage. I know that there was just the commit of using :only on resources to lower memory consumption of routes. Now that we saved that memory we can fill it with other things. I believe that I read an interview with you, David, where you were asked about what is going in the rails core in the next release and you said something along the lines of, ‘It is more like; what is coming out?’ Maybe that isn’t what I heard.

Contributor

adkron replied Nov 18, 2008

So what do things like this do to my load time, and my memory usage. I know that there was just the commit of using :only on resources to lower memory consumption of routes. Now that we saved that memory we can fill it with other things. I believe that I read an interview with you, David, where you were asked about what is going in the rails core in the next release and you said something along the lines of, ‘It is more like; what is coming out?’ Maybe that isn’t what I heard.

@defunkt

This comment has been minimized.

Show comment
Hide comment
@defunkt

defunkt Nov 18, 2008

Contributor

If GitHub had a Hall of Fame, this thread would be the first entry.

Contributor

defunkt replied Nov 18, 2008

If GitHub had a Hall of Fame, this thread would be the first entry.

@ryanb

This comment has been minimized.

Show comment
Hide comment
@ryanb

ryanb Nov 19, 2008

Contributor

@defunkt lol, and this one could be second.

Contributor

ryanb replied Nov 19, 2008

@defunkt lol, and this one could be second.

@mattly

This comment has been minimized.

Show comment
Hide comment
@mattly

mattly Nov 19, 2008

@binarylogic people get worked up for two reasons:
1) it makes rails more complex
2) it widens the gap between rails and “real” ruby, and if you work with non-rails ruby quite frequently, that gap becomes really annoying.

mattly replied Nov 19, 2008

@binarylogic people get worked up for two reasons:
1) it makes rails more complex
2) it widens the gap between rails and “real” ruby, and if you work with non-rails ruby quite frequently, that gap becomes really annoying.

@yairgo

This comment has been minimized.

Show comment
Hide comment
@yairgo

yairgo Nov 19, 2008

Contributor

This is awesome!! Do you think we can add in second_to_last, third_to_last… tenth_to_last??

A few times it was said that this was more for use in the console, which is a strong argument that it really shouldn’t be in the code base.

If you think Array1, Array2 aren’t readable maybe you should find a different hobby/profession.

Contributor

yairgo replied Nov 19, 2008

This is awesome!! Do you think we can add in second_to_last, third_to_last… tenth_to_last??

A few times it was said that this was more for use in the console, which is a strong argument that it really shouldn’t be in the code base.

If you think Array1, Array2 aren’t readable maybe you should find a different hobby/profession.

@amerine

This comment has been minimized.

Show comment
Hide comment
@amerine

amerine Nov 19, 2008

Contributor

if you cannot discern between what ruby does and what rails adds then yes I can see it being a problem…. but maybe the problem is that you don’t know ruby well enough. Rails makes lots of stuff easier, and this just adds to the list.

Personally I don’t mind access to my arrays in that fashion. It makes sense and is pretty readable.

+4 Bonus points for making it even easier for my designer to handle small bits of code.

Contributor

amerine replied Nov 19, 2008

if you cannot discern between what ruby does and what rails adds then yes I can see it being a problem…. but maybe the problem is that you don’t know ruby well enough. Rails makes lots of stuff easier, and this just adds to the list.

Personally I don’t mind access to my arrays in that fashion. It makes sense and is pretty readable.

+4 Bonus points for making it even easier for my designer to handle small bits of code.

@chrislloyd

This comment has been minimized.

Show comment
Hide comment
@chrislloyd

chrislloyd Nov 19, 2008

Contributor

I think we should paint it red.

http://www.freebsd.org/doc/en_US.ISO8859-1/books/faq/misc.html#BIKESHED-PAINTING

Contributor

chrislloyd replied Nov 19, 2008

I think we should paint it red.

http://www.freebsd.org/doc/en_US.ISO8859-1/books/faq/misc.html#BIKESHED-PAINTING

@robbyrussell

This comment has been minimized.

Show comment
Hide comment
@robbyrussell

robbyrussell Nov 19, 2008

Contributor

Let the man have his cake. :-)

Contributor

robbyrussell replied Nov 19, 2008

Let the man have his cake. :-)

@adkron

This comment has been minimized.

Show comment
Hide comment
@adkron

adkron Nov 19, 2008

Contributor

Good point Chris. I like your answer.

Contributor

adkron replied Nov 19, 2008

Good point Chris. I like your answer.

@tedhenry10

This comment has been minimized.

Show comment
Hide comment
@tedhenry10

tedhenry10 Nov 19, 2008

Rails 0.9 was better.

tedhenry10 replied Nov 19, 2008

Rails 0.9 was better.

@boblmartens

This comment has been minimized.

Show comment
Hide comment
@boblmartens

boblmartens Nov 19, 2008

Wait, am I wrong, or do you not have to use this if you don’t want to?

boblmartens replied Nov 19, 2008

Wait, am I wrong, or do you not have to use this if you don’t want to?

@rubyruy

This comment has been minimized.

Show comment
Hide comment
@rubyruy

rubyruy Nov 19, 2008

Contributor

I love this patch.

Contributor

rubyruy replied Nov 19, 2008

I love this patch.

@timander

This comment has been minimized.

Show comment
Hide comment
@timander

timander Nov 19, 2008

On the bright side, Git lets you undo commits as if they never even happened.

timander replied Nov 19, 2008

On the bright side, Git lets you undo commits as if they never even happened.

@brianmario

This comment has been minimized.

Show comment
Hide comment
@brianmario

brianmario Nov 19, 2008

Contributor

for the love of god, you’re all spamming my github dashboard :P

Those of you who hate this patch and want to move to another framework, go ahead. There’s 10x more about to start using Rails anyway.

Those of you who love this patch (and still love rails with it, for that matter) – do you really need to justify yet another spoonful of sugar?

@dhh – keep up the good work, I personally don’t mind if there are a few more methods I can optionally use to make my life easier

Contributor

brianmario replied Nov 19, 2008

for the love of god, you’re all spamming my github dashboard :P

Those of you who hate this patch and want to move to another framework, go ahead. There’s 10x more about to start using Rails anyway.

Those of you who love this patch (and still love rails with it, for that matter) – do you really need to justify yet another spoonful of sugar?

@dhh – keep up the good work, I personally don’t mind if there are a few more methods I can optionally use to make my life easier

@anildigital

This comment has been minimized.

Show comment
Hide comment
@anildigital

anildigital Nov 19, 2008

Contributor

I think the kind of commit is really useful. But should it be part of framework or not, not very sure!

Contributor

anildigital replied Nov 19, 2008

I think the kind of commit is really useful. But should it be part of framework or not, not very sure!

@johnwyles

This comment has been minimized.

Show comment
Hide comment
@johnwyles

johnwyles Nov 19, 2008

Why stop at ten? Why not make some dynamic methods for converting numerics to flattened strings so we can do this for all elements in the array? I for one welcome our new 30+ character representational format!

It is hard not to get excited about such a thing: hella_long_array.one_million_seven_hundred_fifty_five_thousand_two_hundred_sixty_third

Error: Unclosed “” tag.

johnwyles replied Nov 19, 2008

Why stop at ten? Why not make some dynamic methods for converting numerics to flattened strings so we can do this for all elements in the array? I for one welcome our new 30+ character representational format!

It is hard not to get excited about such a thing: hella_long_array.one_million_seven_hundred_fifty_five_thousand_two_hundred_sixty_third

Error: Unclosed “” tag.

@janx

This comment has been minimized.

Show comment
Hide comment
@janx

janx Nov 19, 2008

Contributor

car, cadr, caddr, cadddr, caddddr, cadddddr ..

Contributor

janx replied Nov 19, 2008

car, cadr, caddr, cadddr, caddddr, cadddddr ..

@elisehuard

This comment has been minimized.

Show comment
Hide comment
@elisehuard

elisehuard Nov 19, 2008

@chrislloyd’s answer nails it.

elisehuard replied Nov 19, 2008

@chrislloyd’s answer nails it.

@NZKoz

This comment has been minimized.

Show comment
Hide comment
@NZKoz

NZKoz Nov 19, 2008

Member

Honestly, guys, the amount of effort you’ve expended here rivals only the penis extension thread on trac.

@defunkt: You need to add a STFU button which closes a thread and tells people to take a walk, hug their loved ones, or read a book.

Member

NZKoz replied Nov 19, 2008

Honestly, guys, the amount of effort you’ve expended here rivals only the penis extension thread on trac.

@defunkt: You need to add a STFU button which closes a thread and tells people to take a walk, hug their loved ones, or read a book.

@matthooks

This comment has been minimized.

Show comment
Hide comment
@matthooks

matthooks Nov 19, 2008

cough ibtl cough

matthooks replied Nov 19, 2008

cough ibtl cough

@neilh

This comment has been minimized.

Show comment
Hide comment
@neilh

neilh Nov 19, 2008

“This is awesome!! Do you think we can add in second_to_last, third_to_last… tenth_to_last??” – lol

neilh replied Nov 19, 2008

“This is awesome!! Do you think we can add in second_to_last, third_to_last… tenth_to_last??” – lol

@tidelake

This comment has been minimized.

Show comment
Hide comment
@tidelake

tidelake Nov 19, 2008

Hi. Here is my first github comment. I love this change. It may not be “useful” in the Cartesian sense, but it does subtract some hurt. Love it!

tidelake replied Nov 19, 2008

Hi. Here is my first github comment. I love this change. It may not be “useful” in the Cartesian sense, but it does subtract some hurt. Love it!

@ELLIOTTCABLE

This comment has been minimized.

Show comment
Hide comment
@ELLIOTTCABLE

ELLIOTTCABLE Nov 19, 2008

I’m not going to argue against this — this is essentially, at it’s core, Rails-ish. This is the very reason I don’t use Rails, and I know there’s many others who think like me. There’s a thin line between sugar (Ruby) and bloat (Rails), and it’s useless to complain about Rails crossing it. I agree that Chris should add a feature to GitHub just so he can close this thread and we can all get on with life /=

ELLIOTTCABLE replied Nov 19, 2008

I’m not going to argue against this — this is essentially, at it’s core, Rails-ish. This is the very reason I don’t use Rails, and I know there’s many others who think like me. There’s a thin line between sugar (Ruby) and bloat (Rails), and it’s useless to complain about Rails crossing it. I agree that Chris should add a feature to GitHub just so he can close this thread and we can all get on with life /=

@spiceee

This comment has been minimized.

Show comment
Hide comment
@spiceee

spiceee Nov 19, 2008

I think some people should go back to Java, where such a crime would never be perpetrated.

spiceee replied Nov 19, 2008

I think some people should go back to Java, where such a crime would never be perpetrated.

@nikosd

This comment has been minimized.

Show comment
Hide comment
@nikosd

nikosd Nov 19, 2008

@defunkt: Ok, this commit is one of the reasons I’ve come to lurve github a little more! Don’t ever put a STFU button! (Although it would be useful – to be honest :D)

nikosd replied Nov 19, 2008

@defunkt: Ok, this commit is one of the reasons I’ve come to lurve github a little more! Don’t ever put a STFU button! (Although it would be useful – to be honest :D)

@matthewrudy

This comment has been minimized.

Show comment
Hide comment
@matthewrudy

matthewrudy Nov 19, 2008

Contributor

Yeah.
I think this is great.
A great discussion,
a great argument.

I read the commit logs every day,
but this just makes me happy in a way I never expected.

Thankyou Github.

Contributor

matthewrudy replied Nov 19, 2008

Yeah.
I think this is great.
A great discussion,
a great argument.

I read the commit logs every day,
but this just makes me happy in a way I never expected.

Thankyou Github.

@jamesu

This comment has been minimized.

Show comment
Hide comment
@jamesu

jamesu Nov 19, 2008

I suggest you also add the following methods:

second_from_last, third_from_last, fourth_from_last, fifth_from_last, sixth_from_last, seventh_from_last, eighth_from_last, ninth_from_last, and tenth_from_last.

jamesu replied Nov 19, 2008

I suggest you also add the following methods:

second_from_last, third_from_last, fourth_from_last, fifth_from_last, sixth_from_last, seventh_from_last, eighth_from_last, ninth_from_last, and tenth_from_last.

@gaffo

This comment has been minimized.

Show comment
Hide comment
@gaffo

gaffo Nov 19, 2008

Contributor

@DHH, as you said to me earlier on Lighthouse,

“While I applaud the effort, I think this is not really don’t enough to be worth a [commit] in Rails code. If you use this a lot, I would definitely recommend making a plugin out of it, though.”
-DHH : http://rails.lighthouseapp.com/projects/8994/tickets/1303-scriptgenerate-library

NZKoz : these types of arguments are exactly why rails is a good framework, people are allowed to make comments on things they don’t like.

defunkt: keep it up.

Contributor

gaffo replied Nov 19, 2008

@DHH, as you said to me earlier on Lighthouse,

“While I applaud the effort, I think this is not really don’t enough to be worth a [commit] in Rails code. If you use this a lot, I would definitely recommend making a plugin out of it, though.”
-DHH : http://rails.lighthouseapp.com/projects/8994/tickets/1303-scriptgenerate-library

NZKoz : these types of arguments are exactly why rails is a good framework, people are allowed to make comments on things they don’t like.

defunkt: keep it up.

@dcrec1

This comment has been minimized.

Show comment
Hide comment
@dcrec1

dcrec1 Nov 19, 2008

Contributor

I think it should be in a plugin, maybe with more other aliases

Contributor

dcrec1 replied Nov 19, 2008

I think it should be in a plugin, maybe with more other aliases

@trevorturk

This comment has been minimized.

Show comment
Hide comment
@trevorturk

trevorturk Nov 19, 2008

Contributor

ActiveSupport::CoreExtensions::PradiptasRolodex?

Contributor

trevorturk replied Nov 19, 2008

ActiveSupport::CoreExtensions::PradiptasRolodex?

@Yardboy

This comment has been minimized.

Show comment
Hide comment
@Yardboy

Yardboy Nov 19, 2008

I got into a discussion of this over lunch one day at RubyConf. I’m reminded of George Carlin’s rant about some religious schlub not liking what he heard on the radio. “The radio has two knobs, Reverend… one turns it off, and the other changes the channel!” In other words, if you don’t like it, don’t use it.

That being said, I can’t wait for someone to add #penultimate.

Yardboy replied Nov 19, 2008

I got into a discussion of this over lunch one day at RubyConf. I’m reminded of George Carlin’s rant about some religious schlub not liking what he heard on the radio. “The radio has two knobs, Reverend… one turns it off, and the other changes the channel!” In other words, if you don’t like it, don’t use it.

That being said, I can’t wait for someone to add #penultimate.

@ELLIOTTCABLE

This comment has been minimized.

Show comment
Hide comment
@ELLIOTTCABLE

ELLIOTTCABLE Nov 19, 2008

It’s not about “if you don’t like it, don’t use it”. It’s about it being bloat. It’d be nice if computers could download, upload, transfer, run, and keep in memory an infinite amount of code. They can’t. There’s tons of slightly useful things you could add to Ruby that would be kinda nice, but they’d also be yet more bloat – YMB. Such things shouldn’t be added to Rails.

Wait, what am I saying? This is what Rails is all about. Thar she blows, men! Man the harpoons!

ELLIOTTCABLE replied Nov 19, 2008

It’s not about “if you don’t like it, don’t use it”. It’s about it being bloat. It’d be nice if computers could download, upload, transfer, run, and keep in memory an infinite amount of code. They can’t. There’s tons of slightly useful things you could add to Ruby that would be kinda nice, but they’d also be yet more bloat – YMB. Such things shouldn’t be added to Rails.

Wait, what am I saying? This is what Rails is all about. Thar she blows, men! Man the harpoons!

@ELLIOTTCABLE

This comment has been minimized.

Show comment
Hide comment
@ELLIOTTCABLE

ELLIOTTCABLE Nov 19, 2008

On another note, this epic thread has spawned it’s own meta-commentary: http://tr.im/19fd?stackoverflow

ELLIOTTCABLE replied Nov 19, 2008

On another note, this epic thread has spawned it’s own meta-commentary: http://tr.im/19fd?stackoverflow

@adelcambre

This comment has been minimized.

Show comment
Hide comment
@adelcambre

adelcambre Nov 19, 2008


+ # Equal to self[10]
+ def eleventh
+   self[10]
+ end

Now it goes to eleventh.

adelcambre replied Nov 19, 2008


+ # Equal to self[10]
+ def eleventh
+   self[10]
+ end

Now it goes to eleventh.

@amerine

This comment has been minimized.

Show comment
Hide comment
@amerine

amerine Nov 19, 2008

Contributor

@elliottcable Comments about comments? I love the tubes sometimes.

Contributor

amerine replied Nov 19, 2008

@elliottcable Comments about comments? I love the tubes sometimes.

@pervel

This comment has been minimized.

Show comment
Hide comment
@pervel

pervel Nov 19, 2008

I think DHH is using a Danish keyboard. Typing brackets on a Danish keyboard is actually quite cumbersome. :)

pervel replied Nov 19, 2008

I think DHH is using a Danish keyboard. Typing brackets on a Danish keyboard is actually quite cumbersome. :)

@toretore

This comment has been minimized.

Show comment
Hide comment
@toretore

toretore Nov 19, 2008

Contributor

http://pastie.org/317766

Joking aside, I’ve sometimes typed users.second just because my brain thought it’d work, and yes, [ and ] are a bit of a PITA to type on non-US keyboards.

Contributor

toretore replied Nov 19, 2008

http://pastie.org/317766

Joking aside, I’ve sometimes typed users.second just because my brain thought it’d work, and yes, [ and ] are a bit of a PITA to type on non-US keyboards.

@georgi

This comment has been minimized.

Show comment
Hide comment
@georgi

georgi Nov 19, 2008

Programmers should just use US keyboard layout.

georgi replied Nov 19, 2008

Programmers should just use US keyboard layout.

@unimatrixZxero

This comment has been minimized.

Show comment
Hide comment
@unimatrixZxero

unimatrixZxero Nov 20, 2008

@georgi: Yes they should.

unimatrixZxero replied Nov 20, 2008

@georgi: Yes they should.

@ozataman

This comment has been minimized.

Show comment
Hide comment
@ozataman

ozataman Nov 20, 2008

While I myself use similar patches on a per-app basis, these kinds of extensions are a pure bloat to what otherwise is a great framework.

I understand that Rails is all about agile programming, but there needs to be a level of elegance and succinct quality we should not be willing to go below.

ozataman replied Nov 20, 2008

While I myself use similar patches on a per-app basis, these kinds of extensions are a pure bloat to what otherwise is a great framework.

I understand that Rails is all about agile programming, but there needs to be a level of elegance and succinct quality we should not be willing to go below.

@ashchan

This comment has been minimized.

Show comment
Hide comment
@ashchan

ashchan Nov 20, 2008

@ieure: We programmers from China also need these especially for testers:
foo.第二, foo.第三, foo.第四…

ashchan replied Nov 20, 2008

@ieure: We programmers from China also need these especially for testers:
foo.第二, foo.第三, foo.第四…

@stalcottsmith

This comment has been minimized.

Show comment
Hide comment
@stalcottsmith

stalcottsmith Nov 20, 2008

What a bunch of whiny bitches! I personally vote for .second_from_last or .next_to_last as well. Readability first. Keep it up.

stalcottsmith replied Nov 20, 2008

What a bunch of whiny bitches! I personally vote for .second_from_last or .next_to_last as well. Readability first. Keep it up.

@benatkin

This comment has been minimized.

Show comment
Hide comment
@benatkin

benatkin Nov 20, 2008

I was curious how many comments there were, and rather than looking through my history, I started looking for this commit in the repository. I must say that the rails directory structure is well organized. Everything’s broken down into little bits. Nice use of include.

benatkin replied Nov 20, 2008

I was curious how many comments there were, and rather than looking through my history, I started looking for this commit in the repository. I must say that the rails directory structure is well organized. Everything’s broken down into little bits. Nice use of include.

@julesfern

This comment has been minimized.

Show comment
Hide comment
@julesfern

julesfern Nov 20, 2008

All my arrays have length of eleven, thus this change is useless to me.

julesfern replied Nov 20, 2008

All my arrays have length of eleven, thus this change is useless to me.

@julesfern

This comment has been minimized.

Show comment
Hide comment
@julesfern

julesfern Nov 20, 2008

oh yeah and

%w(second third fourth fifth sixth seventh eighth ninth tenth).each {|n| define_method…..

/facepalm

julesfern replied Nov 20, 2008

oh yeah and

%w(second third fourth fifth sixth seventh eighth ninth tenth).each {|n| define_method…..

/facepalm

@boof

This comment has been minimized.

Show comment
Hide comment
@boof

boof Nov 21, 2008

This should be an initializer. -1

boof replied Nov 21, 2008

This should be an initializer. -1

@henrik

This comment has been minimized.

Show comment
Hide comment
@henrik

henrik Nov 21, 2008

Contributor

Peeja, danski: When I saw this commit back in June, I liked about it that it didn’t involve metaprogramming. If it only spans 2–10, I find this more readable. Also good for RDoc.

Contributor

henrik replied Nov 21, 2008

Peeja, danski: When I saw this commit back in June, I liked about it that it didn’t involve metaprogramming. If it only spans 2–10, I find this more readable. Also good for RDoc.

@bryanthompson

This comment has been minimized.

Show comment
Hide comment
@bryanthompson

bryanthompson Nov 21, 2008

I wonder what Zed has to say about this.

“kris- Commits like this push me closer to Merb.”

+1, and I wonder if Rails could just be split into a Rails-Core and a Rails-More, as well as a Rails-More-dumb_array_methods_and_other_gibberish

bryanthompson replied Nov 21, 2008

I wonder what Zed has to say about this.

“kris- Commits like this push me closer to Merb.”

+1, and I wonder if Rails could just be split into a Rails-Core and a Rails-More, as well as a Rails-More-dumb_array_methods_and_other_gibberish

@redinger

This comment has been minimized.

Show comment
Hide comment
@redinger

redinger Nov 21, 2008

Let’s get Dave Thomas to give a RailsConf Keynote about how we should fork Rails for the people that don’t want convenience methods.

redinger replied Nov 21, 2008

Let’s get Dave Thomas to give a RailsConf Keynote about how we should fork Rails for the people that don’t want convenience methods.

@boblmartens

This comment has been minimized.

Show comment
Hide comment
@boblmartens

boblmartens Nov 21, 2008

I find this entire section of comments fascinating … the say the least.

boblmartens replied Nov 21, 2008

I find this entire section of comments fascinating … the say the least.

@bak

This comment has been minimized.

Show comment
Hide comment
@bak

bak Nov 21, 2008

Contributor

My only objection to this is that we already have myarray.at built into Ruby. It doesn’t start at zero if that sort of thing bothers you, it works no matter how large your array is, it’s less typing, and it doesn’t even require square brackets.

Contributor

bak replied Nov 21, 2008

My only objection to this is that we already have myarray.at built into Ruby. It doesn’t start at zero if that sort of thing bothers you, it works no matter how large your array is, it’s less typing, and it doesn’t even require square brackets.

@henrik

This comment has been minimized.

Show comment
Hide comment
@henrik

henrik Nov 21, 2008

Contributor

bak: Array#at is zero-indexed.

Contributor

henrik replied Nov 21, 2008

bak: Array#at is zero-indexed.

@bak

This comment has been minimized.

Show comment
Hide comment
@bak

bak Nov 22, 2008

Contributor

henrik: so it is. Don’t know where that blip came from.

Contributor

bak replied Nov 22, 2008

henrik: so it is. Don’t know where that blip came from.

@technohippy

This comment has been minimized.

Show comment
Hide comment
@technohippy

technohippy Nov 22, 2008

Hi all,
I pushed ahead with this idea: http://d.hatena.ne.jp/technohippy/20081121#1227285803

technohippy replied Nov 22, 2008

Hi all,
I pushed ahead with this idea: http://d.hatena.ne.jp/technohippy/20081121#1227285803

@Aupajo

This comment has been minimized.

Show comment
Hide comment
@Aupajo

Aupajo Nov 22, 2008

@technohippy

Good god.

Aupajo replied Nov 22, 2008

@technohippy

Good god.

@ZhangHanDong

This comment has been minimized.

Show comment
Hide comment
@ZhangHanDong

ZhangHanDong Nov 23, 2008

~/work/test_222>rails -v
Rails 2.2.2
~/work/test_222>cs
Loading development environment (Rails 2.2.2)

> > arr = [1,2,3,4,5,6,7,8,9,10]
> > => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
> > arr.first
> > => 1
> > arr.second
> > => 2
> > arr.third
> > => 3
> > arr.fourth
> > => 4
> > arr.fifth
> > => 5
> > arr.sixth
> > NoMethodError: undefined method `sixth’ for [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:Array
> > from (irb):7
> > arr.seventh
> > NoMethodError: undefined method`seventh’ for [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:Array
> > from (irb):8
> > arr.eighth
> > NoMethodError: undefined method `eighth’ for [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:Array
> > from (irb):9
> > arr.ninth
> > NoMethodError: undefined method`ninth’ for [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:Array
> > from (irb):10
> > arr.tenth
> > NoMethodError: undefined method `tenth’ for [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:Array
> > from (irb):11

why ???

ps, cs command = ./script/console

ZhangHanDong replied Nov 23, 2008

~/work/test_222>rails -v
Rails 2.2.2
~/work/test_222>cs
Loading development environment (Rails 2.2.2)

> > arr = [1,2,3,4,5,6,7,8,9,10]
> > => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
> > arr.first
> > => 1
> > arr.second
> > => 2
> > arr.third
> > => 3
> > arr.fourth
> > => 4
> > arr.fifth
> > => 5
> > arr.sixth
> > NoMethodError: undefined method `sixth’ for [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:Array
> > from (irb):7
> > arr.seventh
> > NoMethodError: undefined method`seventh’ for [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:Array
> > from (irb):8
> > arr.eighth
> > NoMethodError: undefined method `eighth’ for [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:Array
> > from (irb):9
> > arr.ninth
> > NoMethodError: undefined method`ninth’ for [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:Array
> > from (irb):10
> > arr.tenth
> > NoMethodError: undefined method `tenth’ for [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]:Array
> > from (irb):11

why ???

ps, cs command = ./script/console

@dhh

This comment has been minimized.

Show comment
Hide comment
@dhh

dhh Nov 23, 2008

Member

Zhang: http://github.com/rails/rails/commit/e50530ca3ab5db53ebc74314c54b62b91b932389

Member

dhh replied Nov 23, 2008

Zhang: http://github.com/rails/rails/commit/e50530ca3ab5db53ebc74314c54b62b91b932389

@activars

This comment has been minimized.

Show comment
Hide comment
@activars

activars Nov 28, 2008

at least it’s readable

activars replied Nov 28, 2008

at least it’s readable

@justinko

This comment has been minimized.

Show comment
Hide comment
@justinko

justinko Nov 28, 2008

Contributor

I really like this. What’s wrong with more readable???

Contributor

justinko replied Nov 28, 2008

I really like this. What’s wrong with more readable???

@skrat

This comment has been minimized.

Show comment
Hide comment
@skrat

skrat Apr 3, 2009

To DHH: stop programming, start writing poetry. you are too good for this Ruby thing, because replacing

dhh_dumbideas[2]

with

dhh_dumbideas.second

is the most stupid thing I’ve ever seen. It surely makes the code more readable as you have to read the word instead of a number. thumbs up , just please, don’t become a Ruby core developer

skrat replied Apr 3, 2009

To DHH: stop programming, start writing poetry. you are too good for this Ruby thing, because replacing

dhh_dumbideas[2]

with

dhh_dumbideas.second

is the most stupid thing I’ve ever seen. It surely makes the code more readable as you have to read the word instead of a number. thumbs up , just please, don’t become a Ruby core developer

@skrat

This comment has been minimized.

Show comment
Hide comment
@skrat

skrat Apr 3, 2009

sorry: dhh_dumbideas1

skrat replied Apr 3, 2009

sorry: dhh_dumbideas1

@heycarsten

This comment has been minimized.

Show comment
Hide comment
@heycarsten

heycarsten Apr 3, 2009

skrat, I think you want dhh_dumbideas1 for the second item.

heycarsten replied Apr 3, 2009

skrat, I think you want dhh_dumbideas1 for the second item.

@heycarsten

This comment has been minimized.

Show comment
Hide comment
@heycarsten

heycarsten Apr 3, 2009

Oops, textile.

heycarsten replied Apr 3, 2009

Oops, textile.

@mihael

This comment has been minimized.

Show comment
Hide comment
@mihael

mihael Apr 4, 2009

bla.blunth … did You all see http://kitschmaster.com. it is still built with Rails. I still do not know why, though. Rails is changing faster than my sons teeth are growing. I am continually being challenged to read fresh mostly unusable code. Is this a lack of real communication between all You Souls?

Does any of You guys think a blink about Ruby 4.0?

mihael replied Apr 4, 2009

bla.blunth … did You all see http://kitschmaster.com. it is still built with Rails. I still do not know why, though. Rails is changing faster than my sons teeth are growing. I am continually being challenged to read fresh mostly unusable code. Is this a lack of real communication between all You Souls?

Does any of You guys think a blink about Ruby 4.0?

@edmundsalvacion

This comment has been minimized.

Show comment
Hide comment
@edmundsalvacion

edmundsalvacion Nov 18, 2013

wait.. what's going on?

edmundsalvacion replied Nov 18, 2013

wait.. what's going on?

@joneslee85

This comment has been minimized.

Show comment
Hide comment
@joneslee85

joneslee85 Apr 30, 2014

Contributor

@dhh I welcome such changes to make Rails more human readable, more convenient and more aesthetic..hold on wait, but the assertion test are not English readable at all, reconsidering minitest/spec?

Contributor

joneslee85 replied Apr 30, 2014

@dhh I welcome such changes to make Rails more human readable, more convenient and more aesthetic..hold on wait, but the assertion test are not English readable at all, reconsidering minitest/spec?

@adek23

This comment has been minimized.

Show comment
Hide comment
@adek23

adek23 Aug 9, 2017

[Comment remove by DHH for violating our Code of Conduct on using "sexualized language"]

adek23 replied Aug 9, 2017

[Comment remove by DHH for violating our Code of Conduct on using "sexualized language"]

@ScionOfBytes

This comment has been minimized.

Show comment
Hide comment
@ScionOfBytes

ScionOfBytes Aug 9, 2017

I love how I've found myself here despite the passage of all these years.

ScionOfBytes replied Aug 9, 2017

I love how I've found myself here despite the passage of all these years.

Please sign in to comment.