MindMap Gallery Scala language basics
The Scala language basics summary mind map helps readers comprehensively understand and master the basic concepts and practical skills of the Scala programming language. Whether you are a beginner in programming or an experienced developer, I believe you can get valuable inspiration and gains from this article.
Edited at 2024-11-28 12:53:03Questo è il capitolo 5 del libro dell'insegnante Zhao Zhou "Questo è abbastanza da leggere", che parla principalmente di questi aspetti: ① L'importanza dell'abilità di apprendimento ② Come aggiungere contesto alle informazioni ③ Come distinguere la conoscenza e le informazioni Non mi affretta a mettere in discussione e sfidare ⑤Come usare note appiccicose per aggiornare la capacità di apprendimento ⑥ Perché inseguire i "merci secche" uno pseudo-apprendimento?
Per aiutare tutti a usare DeepSeek in modo più efficiente, è stata compilata una raccolta di Map Mind Mind Guide DeepSeek! Questa mappa mentale riassume il contenuto principale: collegamenti correlati a Yitu, analisi del profilo DS, confronto tra rotte tecnologiche DeepSeek e Chatgpt, Guida di distribuzione del modello DeepSeek e Qwen, come fare più soldi con DeepSeek, come giocare a DeepSeek, DeepSeek Scientific Research Application Aspetta, permettendoti di cogliere rapidamente l'essenza dell'interazione AI. Che si tratti di creazione di contenuti, pianificazione del piano, generazione di codice o miglioramento dell'apprendimento, DeepSeek può aiutarti a ottenere il doppio del risultato con metà dello sforzo!
Questa è una mappa mentale sulle 30 istruzioni a livello di alimentazione di DeepSeek.
Questo è il capitolo 5 del libro dell'insegnante Zhao Zhou "Questo è abbastanza da leggere", che parla principalmente di questi aspetti: ① L'importanza dell'abilità di apprendimento ② Come aggiungere contesto alle informazioni ③ Come distinguere la conoscenza e le informazioni Non mi affretta a mettere in discussione e sfidare ⑤Come usare note appiccicose per aggiornare la capacità di apprendimento ⑥ Perché inseguire i "merci secche" uno pseudo-apprendimento?
Per aiutare tutti a usare DeepSeek in modo più efficiente, è stata compilata una raccolta di Map Mind Mind Guide DeepSeek! Questa mappa mentale riassume il contenuto principale: collegamenti correlati a Yitu, analisi del profilo DS, confronto tra rotte tecnologiche DeepSeek e Chatgpt, Guida di distribuzione del modello DeepSeek e Qwen, come fare più soldi con DeepSeek, come giocare a DeepSeek, DeepSeek Scientific Research Application Aspetta, permettendoti di cogliere rapidamente l'essenza dell'interazione AI. Che si tratti di creazione di contenuti, pianificazione del piano, generazione di codice o miglioramento dell'apprendimento, DeepSeek può aiutarti a ottenere il doppio del risultato con metà dello sforzo!
Questa è una mappa mentale sulle 30 istruzioni a livello di alimentazione di DeepSeek.
Scala language basics
Scala language overview
The origin of computers
Lambda calculus is regarded as the smallest general-purpose programming language
programming paradigm
imperative programming
A programming method that executes instructions sequentially
functional programming
A function-based programming paradigm
Introduction to Scala
Scala runs on the Java Virtual Machine and is compatible with existing Java programs
Scala is a pure object-oriented language
Scala is also a functional language
Scala basics
Basic data types and variables
Basic data types
integer type
Byte
Short
Int
Long
string type
String
Boolean type
Boolean
Character type
Char
floating point type
Float
Double
Basic operations
literal
Operator
Arithmetic operators > Relational operators > Logical operators > Assignment operators
Operators are methods in Scala
Rich packaging
Each basic type has a corresponding rich wrapper class
variable
val
Immutable must be initialized when declared
var
variable
I/O
Console input and output statements
Read and write files
control structure
conditional statement
if
Loop statement
while
for
Exception handling
control over loops
data structure
Array
A mutable, indexable collection of data whose elements are of the same type
Tuple
It is a simple encapsulation of multiple objects of different types.
Container(Collection)
Scala provides a rich set of container libraries, including sequences, collections, mappings, etc.
Sequence
List
An immutable sequence of objects that share the same type
The common way to construct a list is to add elements to the front of an existing list. The operator used is ∷
Once a Scala list is defined, its value cannot be changed. The list must be initialized when declaring it.
Scala also defines an empty list object Ni. With Ni, multiple elements can be connected using the operator "::" to initialize a list.
Vector
All access operations can be implemented in constant time
Range
A special, indexed, immutable arithmetic sequence of numbers
Can support creating numerical sequences of different data types
Set
A container with non-repeating elements that allows you to quickly find an element
Map
A container for a series of key-value pairs
Keys are unique, but values are not necessarily unique
Iterator
It is not a container but a data structure that provides sequential access to the container elements.
next
Can return the next element of the iterator
hasNext
Used to detect whether there is a next element
Two basic operations
Object-oriented programming basics
kind
Define class
Visibility of class members
public
Public members can be directly accessed from any scope
private
Refers to visible to this type and nested types
protected
Visible to both this type and its inherited types
How methods are defined
Val and var cannot be added before method parameters. All method parameters are immutable types.
The definition of a parameterless method can omit the parentheses
Constructor
The definition body of a Scala class is the constructor of the class, called the main constructor
used to create objects
You can use the val or var keyword before the parameters of the main constructor
Scala will actively create private fields for these parameters internally and provide corresponding access methods.
object
Singleton object
Use object key definition
companion object
When a singleton object appears together with its class of the same name, the singleton object at this time is called a companion object of the class of the same name.
isolated object
There is no singleton object of the same class
The apply method receives the parameters of the constructor and turns them into objects. The unapply method receives an object and extracts the value from it.
inherit
Scala only supports single inheritance, not multiple inheritance
abstract class
Using the keyword abstract, abstract fields in abstract classes must declare types, otherwise compilation errors will occur.
Extended class
Option class
Some
valuable
None
no value
Parameterized types
The definition of a class contains one or several undetermined type parameter information, and its specific type will be determined when the class is instantiated.
Trait
Using "traits" to achieve multiple reuse of code not only realizes the function of the interface, but also has many other features
The characteristic of Scala is that it is the basic unit of code reuse and can have both abstract methods and concrete methods.
A class can only inherit from one superclass, but can implement multiple traits
Traits are similar to abstract classes and can contain both abstract and non-abstract members.
Traits can be mixed into classes using the extends or with keywords
pattern matching
match statement
Used in scenarios where you need to choose from multiple branches
There is no need to use the break statement to jump out of the judgment. When a branch is matched from front to back, the judgment will automatically jump out.
case class
Automatically reload many useful methods
Bag
Different parts of the program can be placed in different packages by adding braces after the keyword Package.
Functional programming basics
higher order function
function as parameter
function returns as result
closure
When a function's immediate dependence depends on one or more variables declared outside the function, the function is called a closure.
Partially applied functions and currying
Generating a new function by retaining some parameters of a known function is called a partial application function
Currying
Operations on containers
Traversal operation
foreach()
Mapping operation
map
one-to-one mapping
flatMap
One-to-many mapping "beat flat"
filter operation
filter
protocol operation
reduce
reduceLeft
reduceRight
fold
foldLeft
foldRight
Perform pairwise operations on container elements