About the Authors |
|
xiii | |
About the Technical Reviewer |
|
xv | |
Acknowledgments |
|
xvii | |
Introduction |
|
xix | |
|
Chapter 1 Getting Started with Scala |
|
|
1 | (20) |
|
|
1 | (2) |
|
|
3 | (2) |
|
|
5 | (3) |
|
|
8 | (1) |
|
|
8 | (1) |
|
|
9 | (2) |
|
|
11 | (1) |
|
|
12 | (1) |
|
|
13 | (1) |
|
|
13 | (1) |
|
|
14 | (4) |
|
|
18 | (2) |
|
|
20 | (1) |
|
Chapter 2 Basics of Scala |
|
|
21 | (30) |
|
|
21 | (3) |
|
|
24 | (1) |
|
|
25 | (2) |
|
|
27 | (1) |
|
|
28 | (1) |
|
|
28 | (1) |
|
|
28 | (4) |
|
|
32 | (2) |
|
|
34 | (2) |
|
|
36 | (1) |
|
|
37 | (1) |
|
|
37 | (1) |
|
|
38 | (1) |
|
|
39 | (1) |
|
|
39 | (2) |
|
|
41 | (1) |
|
|
42 | (1) |
|
|
43 | (1) |
|
|
44 | (1) |
|
|
45 | (1) |
|
Running Code Without the REPL |
|
|
45 | (2) |
|
|
47 | (2) |
|
|
49 | (2) |
|
Chapter 3 Object-Oriented Modeling |
|
|
51 | (28) |
|
|
51 | (3) |
|
From Concepts to Concrete Things |
|
|
54 | (2) |
|
|
56 | (2) |
|
|
58 | (1) |
|
|
59 | (4) |
|
|
63 | (2) |
|
|
65 | (2) |
|
|
67 | (1) |
|
|
67 | (2) |
|
|
69 | (1) |
|
|
70 | (1) |
|
|
70 | (1) |
|
|
71 | (1) |
|
|
71 | (1) |
|
|
72 | (1) |
|
|
73 | (1) |
|
|
73 | (2) |
|
|
75 | (1) |
|
|
76 | (3) |
|
Chapter 4 Functional Programming |
|
|
79 | (32) |
|
What Is Functional Programming? |
|
|
80 | (1) |
|
|
81 | (1) |
|
|
82 | (1) |
|
|
82 | (1) |
|
Expression-Oriented Programming |
|
|
83 | (1) |
|
Functions, Lambdas, and Closures |
|
|
84 | (1) |
|
Function Literal/Anonymous Function |
|
|
85 | (3) |
|
First-Class Functions and Higher-Order Functions |
|
|
88 | (3) |
|
|
91 | (1) |
|
Partially Applied Functions |
|
|
92 | (1) |
|
|
93 | (1) |
|
|
94 | (2) |
|
|
96 | (1) |
|
Tail Calls and Tail Call Optimization |
|
|
97 | (2) |
|
Call-by-Name, Call-by-Value, and General Laziness |
|
|
99 | (2) |
|
|
101 | (1) |
|
|
101 | (1) |
|
|
102 | (2) |
|
|
104 | (1) |
|
|
105 | (1) |
|
|
106 | (1) |
|
|
107 | (1) |
|
|
107 | (1) |
|
|
108 | (1) |
|
|
108 | (1) |
|
|
109 | (2) |
|
Chapter 5 Pattern Matching |
|
|
111 | (24) |
|
|
111 | (4) |
|
|
115 | (1) |
|
|
116 | (1) |
|
Pattern Matching in Lists |
|
|
117 | (1) |
|
Pattern Matching and Lists |
|
|
118 | (2) |
|
|
120 | (1) |
|
|
121 | (1) |
|
|
121 | (1) |
|
|
122 | (1) |
|
Pattern Matching with the Matchable Trait |
|
|
122 | (1) |
|
Pattern Matching and Case Classes |
|
|
123 | (2) |
|
Nested Pattern Matching in Case Classes |
|
|
125 | (1) |
|
Pattern Matching as Functions |
|
|
126 | (2) |
|
Pattern Matching on Regular Expressions |
|
|
128 | (1) |
|
Object-Oriented and Functional Tensions |
|
|
129 | (1) |
|
|
130 | (4) |
|
|
134 | (1) |
|
Chapter 6 Scala Collections |
|
|
135 | (38) |
|
Scala Collection Hierarchy |
|
|
136 | (1) |
|
The scala collection Package |
|
|
137 | (3) |
|
The scala collection immutable package |
|
|
140 | (3) |
|
The scala collection mutable package |
|
|
143 | (4) |
|
Using Immutable Collection Classes |
|
|
147 | (1) |
|
|
148 | (2) |
|
|
150 | (8) |
|
|
158 | (1) |
|
|
158 | (2) |
|
|
160 | (1) |
|
|
161 | (3) |
|
|
164 | (1) |
|
|
165 | (1) |
|
|
166 | (1) |
|
|
167 | (1) |
|
Performance of the Collections |
|
|
168 | (2) |
|
|
170 | (3) |
|
Chapter 7 Traits and Enums |
|
|
173 | (24) |
|
|
173 | (2) |
|
|
175 | (4) |
|
Traits and Class Hierarchies |
|
|
179 | (6) |
|
Conflicts of Method Names |
|
|
185 | (1) |
|
Limiting the Use of a Trait |
|
|
186 | (2) |
|
Type Parameters or Type Members |
|
|
188 | (1) |
|
Passing Parameters on Traits |
|
|
189 | (1) |
|
|
189 | (2) |
|
Algebraic Data Types in Enums |
|
|
191 | (2) |
|
Union and Intersection Types |
|
|
193 | (2) |
|
|
195 | (2) |
|
Chapter 8 Scala Type System |
|
|
197 | (22) |
|
|
197 | (3) |
|
|
200 | (1) |
|
|
201 | (7) |
|
|
208 | (1) |
|
|
208 | (1) |
|
|
208 | (2) |
|
|
210 | (1) |
|
|
210 | (1) |
|
|
211 | (3) |
|
Scala 3 Given/Using Clauses |
|
|
214 | (3) |
|
|
217 | (2) |
|
Chapter 9 Scala and Java Interoperability |
|
|
219 | (18) |
|
|
219 | (1) |
|
Translating Java Classes to Scala Classes |
|
|
220 | (2) |
|
Translating Java Imports into Scala Imports |
|
|
222 | (1) |
|
Translating Multiple Constructors |
|
|
223 | (3) |
|
JavaBean Specification-Compliant Scala Classes |
|
|
226 | (2) |
|
Java Interfaces and Scala Traits |
|
|
228 | (2) |
|
Java Static Members and Scala Objects |
|
|
230 | (1) |
|
|
231 | (2) |
|
Java Optional and Scala Option |
|
|
233 | (1) |
|
Use Java Collections in Scala |
|
|
234 | (2) |
|
|
236 | (1) |
|
Chapter 10 DSL and Parser Combinator |
|
|
237 | (10) |
|
|
237 | (2) |
|
|
239 | (6) |
|
|
245 | (1) |
|
|
245 | (2) |
|
Chapter 11 Simple Build Tool |
|
|
247 | (16) |
|
|
249 | (1) |
|
|
249 | (1) |
|
|
250 | (1) |
|
|
250 | (1) |
|
Creating a Hello World Project |
|
|
251 | (2) |
|
|
253 | (4) |
|
|
257 | (1) |
|
LibraryDependencies and Resolvers |
|
|
258 | (2) |
|
|
260 | (1) |
|
|
261 | (2) |
|
Chapter 12 Creating Web Applications |
|
|
263 | (24) |
|
|
263 | (7) |
|
Setting Up the Application |
|
|
270 | (3) |
|
|
273 | (3) |
|
|
276 | (9) |
|
|
285 | (2) |
|
Chapter 13 Testing Your Code |
|
|
287 | (14) |
|
|
287 | (2) |
|
|
289 | (2) |
|
Ignoring the Execution of the Test |
|
|
291 | (1) |
|
Other Ways of Declaring the Test |
|
|
292 | (3) |
|
Using Matchers to Validate Results |
|
|
295 | (1) |
|
|
296 | (2) |
|
|
298 | (1) |
|
|
299 | (2) |
|
Chapter 14 Scala Best Practices |
|
|
301 | (14) |
|
|
301 | (1) |
|
Recognizing the Functional Style |
|
|
302 | (2) |
|
|
304 | (1) |
|
Leveraging Type Inferencing |
|
|
305 | (1) |
|
|
306 | (2) |
|
|
308 | (1) |
|
|
309 | (1) |
|
Using Options Instead of Null Testing |
|
|
310 | (1) |
|
|
311 | (2) |
|
Composing Functions and Classes |
|
|
313 | (1) |
|
|
313 | (2) |
Index |
|
315 | |