An array is a list surrounded by square brackets and separated by commas.
[1, 2, 3]is an array of numbers.
is an array of strings.
['coat', 'mittens', 'snowboard']
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.