spacing hack


solo piano 20100919

I will admit to a bit of Stockholm syndrome since I'm being kidnapped by Ruby for at least a month in preparation for Rails Rumble, but I am finding stuff where I prefer Ruby over Python.

I think I've already mentioned that I like that a lot of methods (?) in Ruby can be called without parantheses. For instance:

"string".length() # equivalent but why bother with those extra characters

I'm also liking the fact that (so far anyway) it seems that most things are methods of the object itself rather than an outside function. For instance, both of these are on the right side:

"string".upper() #Python
"string".upcase #Ruby

Whereas, if you want to get the length of a string, one of them is a left-side thing, and the other is a right-side thing. And why yes, I'm using such fabulous technical terms (I think left-side is a "function" and right-side is a "method"):

len("string")     #Python - left-side
"string".length #Ruby - right-side

I also dig that Ruby has a range function for letters. Like so:


This actually came up a couple months ago, where I wanted to scan through all of the potential country codes to see which ones Google Weather supported (so "AA", "AB" (...) "ZZ"), and the Python equivalent was nowhere near as straightforward:

[chr(i) for i in xrange(ord('A'), ord('Z')+1)]

So it's good that Ruby is proving to be something I actually like, whereas I could never find that same love hidden anywhere in Javascript code.