Simon Willison’s Weblog

Subscribe

If foxes can learn Ruby, why can’t you?

20th February 2004

Why The Lucky Stiff’s (poignant) guide to Ruby is shaping up to be a masterpiece. Trust me, you’ve never read a programming language guide that’s even remotely comparable. Even if you have no interest in Ruby you should check it out, if only for the cartoon foxes. Here’s Why’s explanation of Ruby’s array syntax:

An array is a list surrounded by square brackets and separated by commas.

[1, 2, 3] is an array of numbers.

['coat', 'mittens', 'snowboard'] is an array of strings.

Think of it as a caterpillar which has been stapled into your code. The two square brackets are staples which keep the caterpillar from moving, so you can keep track of which end is the head and which is the tail. The commas are the caterpillar’s legs, wiggling between each section of its body.

Once there was a caterpillar who had commas for legs. Which meant he had to allow a literary pause after each step. The other caterpillars really respected him for it and he came to have quite a commanding presence. Oh, and talk about a philanthropist! He was notorious for giving fresh leaves to those less-fortunate.

The foxes say it best:

More recent articles

This is If foxes can learn Ruby, why can’t you? by Simon Willison, posted on 20th February 2004.

Next: Recommendations for a cheap US dial-up provider?

Previous: Catching up with Harry

Previously hosted at http://simon.incutio.com/archive/2004/02/20/foxes