ARRAY(0xb1a696b4)
Eloquent Ruby (Addison-Wesley Professional Ruby Series) and over one million other books are available for Amazon Kindle. Learn more

Vous voulez voir cette page en français ? Cliquez ici.


or
Sign in to turn on 1-Click ordering.
or
Amazon Prime Free Trial required. Sign up when you check out. Learn More
More Buying Choices
Have one to sell? Sell yours here
Start reading Eloquent Ruby (Addison-Wesley Professional Ruby Series) on your Kindle in under a minute.

Don't have a Kindle? Get your Kindle here, or download a FREE Kindle Reading App.

Eloquent Ruby [Paperback]

Russ Olsen
4.0 out of 5 stars  See all reviews (1 customer review)
List Price: CDN$ 51.99
Price: CDN$ 32.75 & FREE Shipping. Details
You Save: CDN$ 19.24 (37%)
o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o
Only 6 left in stock (more on the way).
Ships from and sold by Amazon.ca. Gift-wrap available.
Want it delivered Tuesday, April 22? Choose One-Day Shipping at checkout.
‹  Return to Product Overview

Table of Contents

Foreword xix

Preface xxi

Acknowledgments xxv

About the Author xxvii

 

PART I: The Basics 1

 

Chapter 1: Write Code That Looks Like Ruby 3

The Very Basic Basics 4

Go Easy on the Comments 6

Camels for Classes, Snakes Everywhere Else 8

Parentheses Are Optional but Are Occasionally Forbidden 9

Folding Up Those Lines 10

Folding Up Those Code Blocks 11

Staying Out of Trouble 12

In the Wild 13

Wrapping Up 15

 

Chapter 2: Choose the Right Control Structure 17

If, Unless, While, and Until 17

Use the Modifier Forms Where Appropriate 19

Use each, Not for 20

A Case of Programming Logic 21

Staying Out of Trouble 23

In the Wild 25

Wrapping Up 27

 

Chapter 3: Take Advantage of Ruby’s Smart Collections 29

Literal Shortcuts 29

Instant Arrays and Hashes from Method Calls 30

Running Through Your Collection 33

Beware the Bang! 36

Rely on the Order of Your Hashes 38

In the Wild 38

Staying Out of Trouble 40

Wrapping Up 42

 

Chapter 4: Take Advantage of Ruby’s Smart Strings 43

Coming Up with a String 44

Another API to Master 47

The String: A Place for Your Lines, Characters, and Bytes 49

In the Wild 50

Staying Out of Trouble 51

Wrapping Up 52

 

Chapter 5: Find the Right String with Regular Expressions 53

Matching One Character at a Time 54

Sets, Ranges, and Alternatives 55

The Regular Expression Star 57

Regular Expressions in Ruby 58

Beginnings and Endings 60

In the Wild 62

Staying Out of Trouble 63

Wrapping Up 64

 

Chapter 6: Use Symbols to Stand for Something 65

The Two Faces of Strings 65

Not Quite a String 66

Optimized to Stand for Something 67

In the Wild 69

Staying Out of Trouble 70

Wrapping Up 71

 

Chapter 7: Treat Everything Like an Object–Because Everything Is 73

A Quick Review of Classes, Instances, and Methods 74

Objects All the Way Down 76

The Importance of Being an Object 77

Public, Private, and Protected 79

In the Wild 81

Staying Out of Trouble 82

Wrapping Up 84

 

Chapter 8: Embrace Dynamic Typing 85

Shorter Programs, But Not the Way You Think 85

Extreme Decoupling 89

Required Ceremony Versus Programmer-Driven Clarity 92

Staying Out of Trouble 93

In the Wild 94

Wrapping Up 96

 

Chapter 9: Write Specs! 97

Test::Unit: When Your Documents Just Have to Work 98

A Plethora of Assertions 101

Don’t Test It, Spec It! 101

A Tidy Spec Is a Readable Spec 104

Easy Stubs 105

. . . And Easy Mocks 107

In the Wild 108

Staying Out of Trouble 110

Wrapping Up 113

 

PART II: Classes, Modules, and Blocks 115

 

Chapter 10: Construct Your Classes from Short, Focused Methods 117

Compressing Specifications 117

Composing Methods for Humans 121

Composing Ruby Methods 122

One Way Out? 123

Staying Out of Trouble 126

In the Wild 127

Wrapping Up 128

 

Chapter 11: Define Operators Respectfully 129

Defining Operators in Ruby 129

A Sampling of Operators 131

Operating Across Classes 134

Staying Out of Trouble 135

In the Wild 137

Wrapping Up 139

 

Chapter 12: Create Classes That Understan...

‹  Return to Product Overview