【目录】 Preface. Part Ⅰ.Core Scala 1.Getting Started with the Scalable Language Installing Scala Using the Scala REPL Summary Exercises 2.Working with Data: Literals, Values, Variables, and Types Values Variables Naming Types Numeric Data Types Strings An Overview of Scala Types Tuples Summary Exercises 3.Expressions and Conditionals Expressions Defining Values and Variables with Expressions Expression Blocks Statements If..Else Expression Blocks If Expressions If—Else Expressions Match Expressions Matching with Wildcard Patterns Matching with Pattern Guards Matching Types with Pattern Variables Loops Iterator Guards Nested Iterators Value Binding While and Do/While Loops Summary Exercises 4.Functions Procedures Functions with Empty Parentheses Function Invocation with Expression Blocks Recursive Functions Nested Functions Calling Functions with Named Parameters Parameters with Default Values Vararg Parameters Parameter Groups Type Parameters Methods and Operators Writing Readable Functions Summary Exercises 5.First—Class Functions Function Types and Values Higher—Order Functions Function Literals Placeholder Syntax Partially Applied Functions and Currying By—Name Parameters Partial Functions Invoking Higher—Order Functions with Function Literal Blocks Summary Exercises 6.Common Collections Lists, Sets, and Maps What's in a List? The Cons Operator List Arithmetic Mapping Lists Reducing Lists Converting Collections Java and Scala Collection Compatibility Pattern Matching with Collections Summary Exercises 7.M0te Collections Mutable Collections Creating New Mutable Collections Creating Mutable Collections from Immutable Ones Using Collection Builders Arrays Seq and Sequences Streams Monadic Collections Option Collections Try Collections Future Collections Summary Exercises Part Ⅱ.Object—Oriented Scala 8.Classes Defining Classes More Class Types Abstract Classes Anonymous Classes More Field and Method Types Overloaded Methods Apply Methods Lazy Values Packaging Accessing Packaged Classes Packaging Syntax Privacy Controls Privacy Access Modifiers Final and Sealed Classes Summary Exercises 9.Objects, Case Classes, and Traits Objects Apply Methods and Companion Objects Command—Line Applications with Objects Case Classes Traits Self Types Instantiation with Traits Importing Instance Members Summary Break——Configuring Your First Scala Project Exercises 10.Advancefl Typing Tuple and Function Value Classes Implicit Parameters Implicit Classes Types Type Aliases Abstract Types Bounded Types Type Variance Package Objects Summary Questions A.Reserved Words Index
【文摘】 An alternate but now unofflcially deprecated syntax you will see for procedures is to define them without the Unit return type and without an equals sign before the procedure body.With this syntax the example log () method would be written like this: scala>def log(d: Double) {println(f"Got value $dth.2f")} log: (d: Double)Unit As just noted, this syntax is unofficially deprecated by the maintainers of the Scala language.The problem with this syntax is that too many developers accidentally wrote procedures with return values, expecting the return value to be actually returned to the caller.With this procedure syntax, any return value (or Fmal expression) will be discarded.To address this problem, it is recommended that developers stick to regular function defmitions with an equals sign to reduce the possibility that valid return values will be ignored. Functions with Empty Parentheses An alternate way to defme and invoke an input—less function (one which has no input parameters) is with empty parentheses.You might fmd this style preferable because it clearly distinguishes the function from a value.
以下为对购买帮助不大的评价