Re:Ruby is beautiful (but I'm moving to Python)
by anthonyb on Monday November 29, 2010 @05:49PM
(#1952156)
I think possibly because it's 'fiddling around the edges'. Sure, it's nice to have a way to reverse a string, but you don't do that very often in practice - assigning to lists, calling functions, etc. are all far more common.
But yeah, I hear you on the downvoting.
# Ruby
string.reverse()
# Python
string[::-1]
Which looks better?
Edit: I'm not sure why this is being down voted. It's a true statement.
Edit2: With all the down voting on Hacker News recently, I'm about to quit sharing my knowledge here. Maybe pg will do something about this. It needs to change otherwise good people will stop posting here.
Edit3:
irb(main):002:0> x = "hacker"
irb(main):003:0> puts x.reverse()
rekcah
>>> x = "hacker"
>>> print x[::-1]
rekcah