Chapter 2 from rubytutorial.org