01. Introduction and installation of Scala 1.1 Scala introductionScala is the Java language scripting, the feature is that the Java language is not scripted to use the script, so that it has a simple script language, WYSIWYG features, and high programming efficiency, fast implementation and other characteristics. In the big Data world, the famous frameworks for Spark and Kafka are written in the
Functional Object
Advantages and disadvantages of immutable object
Adv 1. Immutable objects are more likely to be inferred because they do not change values over time.
Adv 2. immutable objects can be automatically transmitted without changes. To transfer a mutable object, you must first back up the mutable object to prevent modification to the object state in other processes.
Adv 3. The thread cannot change the state of an immutable object (corruption, corruption). It is destined to be thread-sa
1.scala InterpreterThe installation process is similar to a JDK installation, you need to install the JDK first, and then download and install Scala to configure the PATH environment variable.2. Run cmd in the win environment using WIN+R, bring up the command window, execute the callout command①scala Support TAB Command Auto-completion②
As we all know, Scala is a functional programming language of the Geek type, and the features supported include:
The function has a "class citizen" status;
Support for anonymous functions (volume of function numbers)
Supports higher order functions
Support closures
Partial application functions
Currying
The first point to note is that there are two forms of methods and function objects in
(transformation) and the Action (action). The main difference between the two types of functions is that transformation accepts the RDD and returns the RDD, while the action accepts the RDD to return the non-rdd.The transformation operation is deferred, meaning that a conversion operation that generates another RDD from an RDD is not performed immediately, and the operation is actually triggered when there is an action action.The action operator triggers spark to submit job jobs and outputs the
This article describes how to implement the basic Scala language types.Java basic type
Java data types can be roughly divided into two types: Basic (Primitive) Type and object type. There are eight basic types: Boolean, byte, short, Char, Int, long, float, and double. To integrate the basic types into the OO system, Java provides (Wrapper). Package class in packageJava. LangThere are a total of 8 corresponding to the basic types: Boolean, byte, short,
Built-in control structures built-in control structure 1 if control structure
Scala's if structure is the same as that of Java, and the function is not much different. Scala's saying is that if can return a value
Val filename = If (! Args. isempty) ARGs (0) else "default.txt"
This statement is relatively common, but a VaR is not introduced here, but the Val is used.
Println (filename) is equivalent to println (if (! Args. isempty) ARGs (0) else "default.txt"), which is also an advantage of Val,
Note: The Scala version I used is 2.11.8
First, the Hello World code, as follows:
Object helloscala{
def main (args:array[string]): Unit = {
println ("Hello World ...")}
}
Here is a brief description of some of Scala's knowledge Points: first, Scala data types
Scala's data types include: Byte, Char, short, Int, Long, Float, Double, Boolean
Note: Scala
Write in frontThanks to all the friends who came in to see. Yes, I'm currently going to write a book about unity shader.The purpose of the book is to have the following several:
Summarize my experience with unity Shader and give others a reference. I am very aware of the difficulties of learning shader, and I have seen many questions raised by people in the group. I think learning shader is still a
Label: Introduced Scala is a kind of functional object-oriented language . It blends a lot of unprecedented features. At the same time, it executes on top of the JVM . With the growing interest of developers in Scala , and the increasing number of tools to support it, the Scala language will undoubtedly be an indispensable tool in your hands. MongoDB is a product
Win7 installing Scala 2.111. Download Scala 2.11http://download.csdn.net/download/u014393736/7107595I really download the Scala installation files, in fact, is a compressed package, just need to extract the files can be!You can also download the MSI suffix file on the website to install it.The installation process is as follows:The advantage of downloading the MS
The main contents of this section
Trait Construction Order
Comparison of trait and classes
Pre-defined and lazy loading
Trait extension Classes
Self type
1 Trait Construction OrderIn the previous note, we mentioned that for trait that do not have a specific implementation and a field, it will eventually generate a bytecode file that is equivalent to the interface in Java, whereas for trait with specific implementations and fields, the bytecode file is compiled with
Mappings and tuples
Summary :A classic programmer's famous saying is: "If there is only one data structure, then use a hash table." A hash table , or more generally, a mapping , is one of the most flexible data structures. A map is a collection of key/value duality . Scala has a common term: tuples, which are aggregates of N objects, do not necessarily have the same type . duality is simply a n=2 tuple, and tuples are especially useful for
Scala supports associative mappings, such as a key-value pair that can be represented by (key, value)
All types in Scala are objects, including basic data types
The case statement in Scala is used to determine the received message, which is more than the switch...case in Java ... More focusedreceive{Case msg = action ()}
The
In the previous chapter we introduced and then used the interpreter to write simple Scala code, and here's how to write a Hello word! using eclipse
Open Eclipse. Create a new Scala Project. The first new words should be in other, name casually, then create a new Scala Object named "HelloWorld".
Unlike Scala and Java, t
To this chapter, the examples of all function texts refer only to the arguments passed in. For example, (x:int) => x > 0, the only variable used by the function body, x > 0, is x, which is defined as a function argument. However, you can also refer to variables defined elsewhere:
(x:int) => x + much/more.
51CTO Editorial Recommendations: A special topic in Scala programming languages
function to add "more" to the reference, but what is more it. From
=${java_home}/bin:$PATH
5 Execute java-version and javac-version if it can appear the instructions shown in Java installation complete Step Two: Install the Scala https://scala-lang.org/download/page to download1, wget https://downloads.lightbend.com/scala/2.12.6/scala-2.12.6.tgz2, unzip TAR-ZXF
Gitbook set up local book
1, do not login, click Do this later2, click New book–> Enter book name –>confirm3, the path of the book4. Book Display5, Release6, import others book error and introduction7, related documents ———————————————————————-
1, do not login, click Do thi
)), Binop ("+", Var ("x"), Number (1)))ValE2 = Binop ("+", Binop ("/", Var ("x"), Number (2)), Binop ("/", Number (1.5), Var ("x")))ValE3 = Binop ("/", E1, E2)defShow (e:expr) = println (F.format (E) +"\ n") for(e Final Print Effect:1 - * (x + 1)2 x 1.5- + ---2 x 1 - * (x + 1)2 ----------- x 1.5 - + --- 2 x reprint Please indicate the author Jason Ding and its provenanceGitcafe Blog Home page (http://jasonding1354.gitcafe.io/)GitHub Blog Hom
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.