Learning Ruby – Day 5

Day 5 is all about objects and their methods.

Remember a few months back when Apple introduced the Shuffle? Everyone was up-in-arms about it’s lack of screen and how it was useless an mp3 player without a screen is. When in-fact, the lack of screen simplifies and improves the device a great deal.

Ruby is like that; elegant, well thought out, useful, challenging convention. Case in point:

Methods names can end with ‘ =’. Conceptually treating a method’s values as variables. It not only saves keystrokes in comparison to the traditional methodName(value) convention – it more accurately maps to what’s being described.

Add to that, a built-in method for creating read & write methods – attr_accessor, an I’m understanding why Ruby is called the Programmers’ Best Friend.


This post documents my journey through Sam’s Teach Yourself Ruby in 21 days. I’ll be joining Al Abut in his effort to learn Ruby and blog along the way.


Learning Ruby – Day 4

Day 4 – Iterators.

First, all chapters in programming books should start with quotes from Steve Martin .

Second, what’s a language without a convoluted loop syntax to geek out on? Geeez. I thought the purpose of learning to program was the same as learning Arabic from the Defense Language Institute – “because you can’t.” Ruby has iterators for logical, readable code? This means I might actually get something built rather than just debugging loops.

I’ve mentioned before how much I enjoy Slagell’s writing. I also like how the solutions to the exercises are listed immediately after the exercises. This isn’t typical, at in my collection of programming books. It makes getting un-stuck and getting the point much quicker.

Tip: Here’s how I’m remembering how the ‘step’ iterator works:

start.step(to, by)

an example to display all the odd numbers from 5 to -15

5.step(-15, -2)

Quite a few years back I was talking with a programmer/designer (in contrast to my designer/programmer) who didn’t like AppleScript because it was “too much like English”. With syntax like:

  • 3.times to do something, well, 3 times and
  • 10.downto(1) to count down from 10 to 1

I don’t think he’d like Ruby for the exact same reason – if not more so.


This post documents my journey through Sam’s Teach Yourself Ruby in 21 days. I’ll be joining Al Abut in his effort to learn Ruby and blog along the way.