See: Scala for the Impatient, 2nd Edition, by Cay Horstmann, Publisher : Addison-Wesley Professional; 2nd edition (December 28, 2016)
- https://learning.oreilly.com/library/view/scala-for-the/9780134540627
- https://horstmann.com/scala
- https://smile.amazon.com/Scala-Impatient-Cay-S-Horstmann-ebook-dp-B01MR67YSO/dp/B01MR67YSO
Interest in the Scala programming language continues to grow for many reasons. Scala embraces the functional programming style without abandoning the object-oriented paradigm, and it allows you to write programs more concisely than in Java. Because Scala runs on the JVM, it can access any Java library and is interoperable with familiar Java frameworks. Scala also makes it easier to leverage the full power of concurrency.
Written for experienced Java, C++, or C# programmers who are new to Scala or functional programming, Scala for the Impatient, Second Edition, introduces the key Scala concepts and techniques you need in order to be productive quickly. It is the perfect introduction to the language, particularly for impatient readers who want to learn the fundamentals of Scala so they can start coding quickly. It doesn’t attempt to exhaustively list all the features of the language or make you suffer through long and contrived examples. Instead, carefully crafted examples and hands-on activities guide you through well-defined stages of competency, from basic to expert.
This revised edition has been thoroughly updated for Scala 2.12 and reflects current Scala usage. It includes added coverage of recent Scala features, including string interpolation, dynamic invocation, implicit classes, and futures. Scala is a big language, but you can use it effectively without knowing all of its details intimately. This title provides precisely the information that you need to get started in compact, easy-to-understand chunks.
Get started quickly with Scala’s interpreter, syntax, tools, and unique idioms
Master core language features: functions, arrays, maps, tuples, packages, imports, exception handling, and more
Become familiar with object-oriented programming in Scala: classes, inheritance, and traits
Use Scala for real-world programming tasks: working with files, regular expressions, and XML
Work with higher-order functions and the powerful Scala collections library
Leverage Scala’s powerful pattern matching and case classes
Create concurrent programs with Scala futures
Implement domain-specific languages
Understand the Scala type system
Apply advanced “power tools,” such as annotations, implicits, and type classes
Register your product at informit.com/register for convenient access to downloads, updates, and corrections as they become available.
Resources
Purchase book: http://www.informit.com/title/9780134540566
About the Author
Cay S. Horstmann is principal author of Core Java®, Volumes I & II, Tenth Edition (Prentice Hall), as well as a dozen other books for professional programmers and computer science students. He is a professor of computer science at San Jose State University and a Java Champion.
Table of Contents:
- About This E-Book
- Title Page
- Copyright Page
- Dedication Page
- Contents
- Foreword To The First Edition
- Preface
- About The Author
- Chapter 1. The Basics
- 1.1 The Scala Interpreter
- 1.2 Declaring Values and Variables
- 1.3 Commonly Used Types
- 1.4 Arithmetic and Operator Overloading
- 1.5 More about Calling Methods
- 1.6 The apply Method
- 1.7 Scaladoc
- Exercises
- Chapter 2. Control Structures And Functions
- 2.1 Conditional Expressions
- 2.2 Statement Termination
- 2.3 Block Expressions and Assignments
- 2.4 Input and Output
- 2.5 Loops
- 2.6 Advanced for Loops
- 2.7 Functions
- 2.8 Default and Named Arguments
- 2.9 Variable Arguments
- 2.10 Procedures
- 2.11 Lazy Values
- 2.12 Exceptions
- Exercises
- Chapter 3. Working With Arrays
- 3.1 Fixed-Length Arrays
- 3.2 Variable-Length Arrays: Array Buffers
- 3.3 Traversing Arrays and Array Buffers
- 3.4 Transforming Arrays
- 3.5 Common Algorithms
- 3.6 Deciphering Scaladoc
- 3.7 Multidimensional Arrays
- 3.8 Interoperating with Java
- Exercises
- Chapter 4. Maps And Tuplesqueue
- 4.1 Constructing a Map
- 4.2 Accessing Map Values
- 4.3 Updating Map Values
- 4.4 Iterating over Maps
- 4.5 Sorted Maps
- 4.6 Interoperating with Java
- 4.7 Tuples
- 4.8 Zipping
- Exercises
- Chapter 5. Classesqueue
- 5.1 Simple Classes and Parameterless Methods
- 5.2 Properties with Getters and Setters
- 5.3 Properties with Only Getters
- 5.4 Object-Private Fields
- 5.5 Bean Properties
- 5.6 Auxiliary Constructors
- 5.7 The Primary Constructor
- 5.8 Nested Classes
- Exercises
- Chapter 6. Objectsqueue
- 6.1 Singletons
- 6.2 Companion Objects
- 6.3 Objects Extending a Class or Trait
- 6.4 The apply Method
- 6.5 Application Objects
- 6.6 Enumerations
- Exercises
- Chapter 7. Packages And Importsqueue
- 7.1 Packages
- 7.2 Scope Rules
- 7.3 Chained Package Clauses
- 7.4 Top-of-File Notation
- 7.5 Package Objects
- 7.6 Package Visibility
- 7.7 Imports
- 7.8 Imports Can Be Anywhere
- 7.9 Renaming and Hiding Members
- 7.10 Implicit Imports
- Exercises
- Chapter 8. Inheritancequeue
- 8.1 Extending a Class
- 8.2 Overriding Methods
- 8.3 Type Checks and Casts
- 8.4 Protected Fields and Methods
- 8.5 Superclass Construction
- 8.6 Overriding Fields
- 8.7 Anonymous Subclasses
- 8.8 Abstract Classes
- 8.9 Abstract Fields
- 8.10 Construction Order and Early Definitions
- 8.11 The Scala Inheritance Hierarchy
- 8.12 Object Equality
- 8.13 Value Classes
- Exercises
- Chapter 9. Files And Regular Expressionsqueue
- 9.1 Reading Lines
- 9.2 Reading Characters
- 9.3 Reading Tokens and Numbers
- 9.4 Reading from URLs and Other Sources
- 9.5 Reading Binary Files
- 9.6 Writing Text Files
- 9.7 Visiting Directories
- 9.8 Serialization
- 9.9 Process Control
- 9.10 Regular Expressions
- 9.11 Regular Expression Groups
- Exercises
- Chapter 10. Traitsqueue
- 10.1 Why No Multiple Inheritance?
- 10.2 Traits as Interfaces
- 10.3 Traits with Concrete Implementations
- 10.4 Objects with Traits
- 10.5 Layered Traits
- 10.6 Overriding Abstract Methods in Traits
- 10.7 Traits for Rich Interfaces
- 10.8 Concrete Fields in Traits
- 10.9 Abstract Fields in Traits
- 10.10 Trait Construction Order
- 10.11 Initializing Trait Fields
- 10.12 Traits Extending Classes
- 10.13 Self Types
- 10.14 What Happens under the Hood
- Exercises
- Chapter 11. Operatorsqueue
- 11.1 Identifiers
- 11.2 Infix Operators
- 11.3 Unary Operators
- 11.4 Assignment Operators
- 11.5 Precedence
- 11.6 Associativity
- 11.7 The apply and update Methods
- 11.8 Extractors
- 11.9 Extractors with One or No Arguments
- 11.10 The unapplySeq Method
- 11.11 Dynamic Invocation
- Exercises
- Chapter 12. Higher-Order Functionsqueue
- 12.1 Functions as Values
- 12.2 Anonymous Functions
- 12.3 Functions with Function Parameters
- 12.4 Parameter Inference
- 12.5 Useful Higher-Order Functions
- 12.6 Closures
- 12.7 SAM Conversions
- 12.8 Currying
- 12.9 Control Abstractions
- 12.10 The return Expression
- Exercises
- Chapter 13. Collectionsqueue
- 13.1 The Main Collections Traits
- 13.2 Mutable and Immutable Collections
- 13.3 Sequences
- 13.4 Lists
- 13.5 Sets
- 13.6 Operators for Adding or Removing Elements
- 13.7 Common Methods
- 13.8 Mapping a Function
- 13.9 Reducing, Folding, and Scanning
- 13.10 Zipping
- 13.11 Iterators
- 13.12 Streams
- 13.13 Lazy Views
- 13.14 Interoperability with Java Collections
- 13.15 Parallel Collections
- Exercises
- Chapter 14. Pattern Matching And Case Classesqueue
- 14.1 A Better Switch
- 14.2 Guards
- 14.3 Variables in Patterns
- 14.4 Type Patterns
- 14.5 Matching Arrays, Lists, and Tuples
- 14.6 Extractors
- 14.7 Patterns in Variable Declarations
- 14.8 Patterns in for Expressions
- 14.9 Case Classes
- 14.10 The copy Method and Named Parameters
- 14.11 Infix Notation in case Clauses
- 14.12 Matching Nested Structures
- 14.13 Are Case Classes Evil?
- 14.14 Sealed Classes
- 14.15 Simulating Enumerations
- 14.16 The Option Type
- 14.17 Partial Functions
- Exercises
- Chapter 15. Annotationsqueue
- 15.1 What Are Annotations?
- 15.2 What Can Be Annotated?
- 15.3 Annotation Arguments
- 15.4 Annotation Implementations
- 15.5 Annotations for Java Features
- 15.5.1 Java Modifiers
- 15.5.2 Marker Interfaces
- 15.5.3 Checked Exceptions
- 15.5.4 Variable Arguments
- 15.5.5 JavaBeans
- 15.6 Annotations for Optimizations
- 15.6.1 Tail Recursion
- 15.6.2 Jump Table Generation and Inlining
- 15.6.3 Eliding Methods
- 15.6.4 Specialization for Primitive Types
- 15.7 Annotations for Errors and Warnings
- Exercises
- Chapter 16. XML Processingqueue
- 16.1 XML Literals
- 16.2 XML Nodes
- 16.3 Element Attributes
- 16.4 Embedded Expressions
- 16.5 Expressions in Attributes
- 16.6 Uncommon Node Types
- 16.7 XPath-like Expressions
- 16.8 Pattern Matching
- 16.9 Modifying Elements and Attributes
- 16.10 Transforming XML
- 16.11 Loading and Saving
- 16.12 Namespaces
- Exercises
- Chapter 17. Futuresqueue
- 17.1 Running Tasks in the Future
- 17.2 Waiting for Results
- 17.3 The Try Class
- 17.4 Callbacks
- 17.5 Composing Future Tasks
- 17.6 Other Future Transformations
- 17.7 Methods in the Future Object
- 17.8 Promises
- 17.9 Execution Contexts
- Exercises
- Chapter 18. Type Parametersqueue
- 18.1 Generic Classes
- 18.2 Generic Functions
- 18.3 Bounds for Type Variables
- 18.4 View Bounds
- 18.5 Context Bounds
- 18.6 The ClassTag Context Bound
- 18.7 Multiple Bounds
- 18.8 Type Constraints
- 18.9 Variance
- 18.10 Co- and Contravariant Positions
- 18.11 Objects Can’t Be Generic
- 18.12 Wildcards
- Exercises
- Chapter 19. Advanced Typesqueue
- 19.1 Singleton Types
- 19.2 Type Projections
- 19.3 Paths
- 19.4 Type Aliases
- 19.5 Structural Types
- 19.6 Compound Types
- 19.7 Infix Types
- 19.8 Existential Types
- 19.9 The Scala Type System
- 19.10 Self Types
- 19.11 Dependency Injection
- 19.12 Abstract Types
- 19.13 Family Polymorphism
- 19.14 Higher-Kinded Types
- Exercises
- Chapter 20. Parsingqueue
- 20.1 Grammars
- 20.2 Combining Parser Operations
- 20.3 Transforming Parser Results
- 20.4 Discarding Tokens
- 20.5 Generating Parse Trees
- 20.6 Avoiding Left Recursion
- 20.7 More Combinators
- 20.8 Avoiding Backtracking
- 20.9 Packrat Parsers
- 20.10 What Exactly Are Parsers?
- 20.11 Regex Parsers
- 20.12 Token-Based Parsers
- 20.13 Error Handling
- Exercises
- Chapter 21. Implicitsqueue
- 21.1 Implicit Conversions
- 21.2 Using Implicits for Enriching Existing Classes
- 21.3 Importing Implicits
- 21.4 Rules for Implicit Conversions
- 21.5 Implicit Parameters
- 21.6 Implicit Conversions with Implicit Parameters
- 21.7 Context Bounds
- 21.8 Type Classes
- 21.9 Evidence
- 21.10 The @implicitNotFound Annotation
- 21.11 CanBuildFrom Demystified
- Exercises
- Index