Commit
…gh Array#[9] [DHH]
- Loading branch information
There are no files selected for viewing
106 comments
on commit 22af62c
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point Chris. I like your answer.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rails 0.9 was better.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, am I wrong, or do you not have to use this if you don’t want to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love this patch.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On the bright side, Git lets you undo commits as if they never even happened.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the kind of commit is really useful. But should it be part of framework or not, not very sure!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
car, cadr, caddr, cadddr, caddddr, cadddddr ..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chrislloyd’s answer nails it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cough ibtl cough
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
“This is awesome!! Do you think we can add in second_to_last, third_to_last… tenth_to_last??” – lol
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 /=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think some people should go back to Java, where such a crime would never be perpetrated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it should be in a plugin, maybe with more other aliases
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ActiveSupport::CoreExtensions::PradiptasRolodex?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On another note, this epic thread has spawned it’s own meta-commentary: http://tr.im/19fd?stackoverflow
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+ # Equal to self[10]
+ def eleventh
+ self[10]
+ end
Now it goes to eleventh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elliottcable Comments about comments? I love the tubes sometimes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think DHH is using a Danish keyboard. Typing brackets on a Danish keyboard is actually quite cumbersome. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Programmers should just use US keyboard layout.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@georgi: Yes they should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ieure: We programmers from China also need these especially for testers:
foo.第二, foo.第三, foo.第四…
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What a bunch of whiny bitches! I personally vote for .second_from_last or .next_to_last as well. Readability first. Keep it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All my arrays have length of eleven, thus this change is useless to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh yeah and
%w(second third fourth fifth sixth seventh eighth ninth tenth).each {|n| define_method…..
/facepalm
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be an initializer. -1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find this entire section of comments fascinating … the say the least.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
bak: Array#at
is zero-indexed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
henrik: so it is. Don’t know where that blip came from.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi all,
I pushed ahead with this idea: http://d.hatena.ne.jp/technohippy/20081121#1227285803
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@technohippy
Good god.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
~/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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Zhang: http://github.com/rails/rails/commit/e50530ca3ab5db53ebc74314c54b62b91b932389
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
at least it’s readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really like this. What’s wrong with more readable???
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry: dhh_dumbideas1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
skrat, I think you want dhh_dumbideas1 for the second item.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops, textile.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wait.. what's going on?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@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?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[Comment remove by DHH for violating our Code of Conduct on using "sexualized language"]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love how I've found myself here despite the passage of all these years.
What’s with the redundant comments?