Learn to Program, 2nd Edition

Book description

For this new edition of the best-selling Learn to Program, Chris Pine has taken a good thing and made it even better. First, he used the feedback from hundreds of reader e-mails to update the content and make it even clearer. Second, he updated the examples in the book to use the latest stable version of Ruby, and also to use code that looks more like real-world Ruby code, so that people who have just learned to program will be more familiar with common Ruby techniques.

Not only does the Second Edition now include answers to all of the exercises, it includes them twice. First you'll find the "how you could do it" answers, using the techniques you've learned up to that point in the book. Next you'll see "how Chris Pine would do it": answers using more advanced Ruby techniques, to whet your appetite as well as providing sort of a "Rosetta Stone" for more elegant solutions.

Table of contents

  1. Learn to Program
    1. Copyright
    2. For the Best Reading Experience...
    3. Table of Contents
    4. Preface to the Second Edition
    5. Introduction
      1. What Is Programming?
      2. Programming Languages
      3. The Art of Programming
    6. Chapter 1: Getting Started
      1. Windows
      2. Mac OS X
      3. Linux
    7. Chapter 2: Numbers
      1. Did It Work?
      2. Introduction to puts
      3. Integer and Float
      4. Simple Arithmetic
      5. A Few Things to Try
    8. Chapter 3: Letters
      1. String Arithmetic
      2. 12 vs. ’12’
      3. Problems
    9. Chapter 4: Variables and Assignment
    10. Chapter 5: Mixing It Up
      1. Conversions
      2. Another Look at puts
      3. The gets Method
      4. Did It Work?
      5. The chomp Method
      6. A Few Things to Try
      7. Mind Your Variables
    11. Chapter 6: More About Methods
      1. Fancy String Methods
      2. A Few Things to Try
      3. Higher Math
      4. More Arithmetic
      5. Random Numbers
      6. The Math Object
    12. Chapter 7: Flow Control
      1. Comparison Methods
      2. Branching
      3. Looping
      4. A Little Bit of Logic
      5. A Few Things to Try
    13. Chapter 8: Arrays and Iterators
      1. The Method each
      2. More Array Methods
      3. A Few Things to Try
    14. Chapter 9: Writing Your Own Methods
      1. Method Parameters
      2. Local Variables
      3. Experiment: Duby
      4. Return Values
      5. A Few Things to Try
    15. Chapter 10: 10:
      1. Recursion
      2. Rite of Passage: Sorting
      3. A Few Things to Try
      4. One More Example
      5. A Few More Things to Try
    16. Chapter 11: Reading and Writing, Saving and Loading, Yin and…Something Else
      1. Doing Something
      2. The Thing About Computers…
      3. Saving and Loading for Grown-Ups
      4. YAML
      5. Diversion: Double-Quoted Strings
      6. Back to Our Regularly Scheduled Programming
      7. Renaming Your Photos
      8. A Few Things to Try
    17. Chapter 12: New Classes of Objects
      1. The Time Class
      2. A Few Things to Try
      3. The Hash Class
      4. Ranges
      5. Stringy Superpowers
      6. A Few More Things to Try
      7. Classes and the Class Class
    18. Chapter 13: Creating New Classes, Changing Existing Ones
      1. A Few Things to Try
      2. Creating Classes
      3. Instance Variables
      4. new vs. initialize
      5. Baby Dragon
      6. A Few More Things to Try
    19. Chapter 14: Blocks and Procs
      1. Methods That Take Procs
      2. Methods That Return Procs
      3. Passing Blocks (Not Procs) into Methods
      4. A Few Things to Try
    20. Chapter 15: Beyond This Fine Book
      1. irb: Interactive Ruby
      2. The PickAxe: Programming Ruby
      3. Ruby-Talk: The Ruby Mailing List
      4. Tim Toady
      5. THE END
    21. Appendix 1: Possible Solutions
      1. 2:
      2. 5:
      3. 6:
      4. 7:
      5. 8:
      6. 9:
      7. 10:
      8. 11:
      9. 12:
      10. 13:
      11. 14:
      12. You May Be Interested In…

Product information

  • Title: Learn to Program, 2nd Edition
  • Author(s): Chris Pine
  • Release date: March 2009
  • Publisher(s): Pragmatic Bookshelf
  • ISBN: 9781934356364