You are previewing Eloquent Ruby.

Eloquent Ruby

Cover of Eloquent Ruby by Russ Olsen Published by Addison-Wesley Professional
  1. Title Page
  2. Copyright Page
  3. Praise for Eloquent Ruby
  4. Contents
  5. Foreword
  6. Preface
  7. Acknowledgments
  8. About the Author
  9. Part I. The Basics
    1. Chapter 1. Write Code That Looks Like Ruby
    2. Chapter 2. Choose the Right Control Structure
    3. Chapter 3. Take Advantage of Ruby’s Smart Collections
    4. Chapter 4. Take Advantage of Ruby’s Smart Strings
    5. Chapter 5. Find the Right String with Regular Expressions
    6. Chapter 6. Use Symbols to Stand for Something
    7. Chapter 7. Treat Everything Like an Object—Because Everything Is
    8. Chapter 8. Embrace Dynamic Typing
    9. Chapter 9. Write Specs!
  10. Part II. Classes, Modules, and Blocks
    1. Chapter 10. Construct Your Classes from Short, Focused Methods
    2. Chapter 11. Define Operators Respectfully
    3. Chapter 12. Create Classes That Understand Equality
    4. Chapter 13. Get the Behavior You Need with Singleton and Class Methods
    5. Chapter 14. Use Class Instance Variables
    6. Chapter 15. Use Modules as Name Spaces
    7. Chapter 16. Use Modules as Mixins
    8. Chapter 17. Use Blocks to Iterate
    9. Chapter 18. Execute Around with a Block
    10. Chapter 19. Save Blocks to Execute Later
  11. Part III. Metaprogramming
    1. Chapter 20. Use Hooks to Keep Your Program Informed
    2. Chapter 21. Use method_missing for Flexible Error Handling
    3. Chapter 22. Use method_missing for Delegation
    4. Chapter 23. Use method_missing to Build Flexible APIs
    5. Chapter 24. Update Existing Classes with Monkey Patching
    6. Chapter 25. Create Self-Modifying Classes
    7. Chapter 26. Create Classes That Modify Their Subclasses
  12. Part IV. Pulling It All Together
    1. Chapter 27. Invent Internal DSLs
    2. Chapter 28. Build External DSLs for Flexible Syntax
    3. Chapter 29. Package Your Programs as Gems
    4. Chapter 30. Know Your Ruby Implementation
    5. Chapter 31. Keep an Open Mind to Go with Those Open Classes
  13. Appendix. Going Further
  14. Index
  15. Footnotes
    1. Preface
    2. Acknowledgments
    3. Chapter 1
    4. Chapter 2
    5. Chapter 3
    6. Chapter 4
    7. Chapter 5
    8. Chapter 6
    9. Chapter 7
    10. Chapter 8
    11. Chapter 9
    12. Chapter 10
    13. Chapter 11
    14. Chapter 12
    15. Chapter 13
    16. Chapter 14
    17. Chapter 15
    18. Chapter 16
    19. Chapter 17
    20. Chapter 18
    21. Chapter 19
    22. Chapter 20
    23. Chapter 21
    24. Chapter 22
    25. Chapter 23
    26. Chapter 24
    27. Chapter 25
    28. Chapter 26
    29. Chapter 27
    30. Chapter 28
    31. Chapter 29
    32. Chapter 30
    33. Chapter 31
O'Reilly logo

Chapter 6. Use Symbols to Stand for Something

I have to admit that I tend to be a bit anthropomorphic about the technologies I work with. I just can’t help but think of all those complex piles of software as somehow alive, each with its own personality—sometimes friendly, sometimes not. Early in my career I imagined FORTRAN as a grouchy old camel—capable of carrying a huge load, but fairly ugly and not a creature you would want to turn your back on. Later on I had this mental image of the -> operator in the C programming language (it dereferences pointers) as an arrow in flight: also very powerful, also nothing to mess with. These days, the colon that precedes every Ruby symbol always makes me think of the eyes peering out from the tilted head ...

The best content for your career. Discover unlimited learning on demand for around $1/day.