更新时间:2021-07-23 17:24:55
封面
Professional Scala
Why Subscribe?
PacktPub.com
Contributors
About the Authors
Preface
Who This Book Is For
What This Book Covers
What You Need for This Book
Conventions
Installation and Setup
Installing IntelliJ IDE
Installing Scala plugin (make heading)
Reader Feedback
Customer Support
Downloading the Example Code
Errata
Piracy
Questions
Chapter 1. Setting up the Development Environment
Simple Program
Definitions: Packages Imports and Objects
Inside main
Structure of a Scala Project
Basic sbt Commands
Activity: Performing Basic Operations with sbt: Build Run Package
IDE
Activity: Loading and Running a Sample Project in the IDE
REPL
Obtaining the Time Request from Our Chatbot Program
Base Syntax
Base Syntax for Definitions
Base Syntax for Expressions
Unit Testing
Adding a Test to Our Project
Inside Tests
Running Tests for Chatbot
Summary
Chapter 2. Basic Language Features
Objects Classes and Traits
Object
Classes
Equality and Case Classes
Pattern Matching
Traits
Self-Types
Special Classes
OO in Our Chatbot
Decoupling Logic and Environment
Sealed Traits and Algebraic Datatypes
Function Calls
Syntax Goodies
Implementing + in CartesianPoint
Parameter-Passing Mode
By Value
By Name
By Need
Creating a Runnable Construction
Printing the log Argument to the Console and File
Chapter 3. Functions
Functions
Function Values
Function from an OO Point of View
Conversions
Defining and Measuring the Time of a Unit Function
Syntax Sugar in a Function Definition
Partial Functions
Exploring Pattern Matching
Binding a Sequence of Variables in the Pattern Matcher
Partial Functions in Practice
Representing ChatbotMode as a Partial Function
Implementing RemindStore as a Set of Partial Functions
Using Lifting for Conversations between Total and Partial Functions
Chapter 4. Scala Collections
Working with Lists
Constructing Lists
Operations on Lists
Pattern Matching on Lists
First-Order Methods on List
Appending and Concatenation
Taking the Length of a List
Reversing a List
Prefixes and Suffixes
Element Selection
Display
Activity: Creating a New Mode for Chatbot Using Lists
Abstracting on Sequences
The Traversable Trait
Iterators
Streams
Activity: Implementing Fibonacci Series Using Streams and Iterators
Other Collections
Sets
Tuples
Maps
Mutable and Immutable Collections