Aaron N. Tubbs bio photo

Aaron N. Tubbs

Dragon chaser.

Twitter Facebook Google+ LinkedIn Github

I’ll just cut to the chase — this is just more babbling about the genius of Ruby.

  • Ruby includes some really clever syntactic sugar. A great example of this is squeeze, something that culls recurring runs of characters. This is handy in and of itself (though easy enough to implement with loops or regular expressions), but what I learned while learning about squeeze is this: Append a ‘!’ to the squeeze message, and it modifies the string in place rather than just returning a modified version of the object. This is a generalized feature, so something like the message ‘aWord = aWord.downcase’ looks much better as ‘aWord.downcase!’ and is more efficient, since we don’t have to allocate a new object to pull it off. PURE GENIUS.
  • Range objects in Ruby implement things like min and max by default. This makes a lot of sense, since one is holding the starting and ending point of the range, but it’s the type of elegant stuff that I really appreciate. Similarly, it’s easy to pull out whether or not a range includes a certain value, since you can figure out if it falls between the min and max … but why struggle for it? Ruby doesn’t make you.
  • Ruby allows you to serialize from and deserialize to arrays in method calls. Fantastic!
  • There is a website out there that collects “what if” letters that people wish they could give to their bosses to let them know how they feel. Fantastic as well! Ok, that had nothing to do with Ruby.