Why’s (Poignant) Guide to Ruby: Arrays


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.

Yes, an array is a collection of things, but it also keeps those things in a specific order.

This is really a hilarious book!
I felt compelled to blog that quote 🙂  and now, I will continue reading…


“Hopefully, you’re seeing some patterns in Ruby. If not, just shake your head vigorously while you’ve got these examples in your mind. The code should break apart into manageable pieces.”

I am also reading “Learn You a Haskell for Great Good!”, in hardcopy from the Coburg library. It’s not quite so humorous as the Poignant guide, but has its moments of hilarity… and Haskell is an awesome language.


This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s