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
In the next step, we will implement the method above in the class element. Putting one element above another means concatenating the contents values of these two elements. So the first draft of method above might look like this:
def above (that:element): Element =
new Arrayelement (this.contents + + that.contents)
The + + operator concatenates two arrays. The array in Scala is represented as a Java array, but it supports more methods. In particular
Domain-specific languages have become a hot topic; Many functional languages are popular, mainly because they can be used to build domain-specific languages. For this reason, in the 8th article in the Scala Guide series for Java™ developers, Ted Neward to build a simple calculator DSL to demonstrate the power of building an "external" DSL for functional languages. He examines a new feature of Scala: Case cl
The latest project to use the Spark platform, whether it is to see the source code or writing programs need to use the Scala language, after two days of contact, the map map here a bit of doubt, do a bit of testing after a note of their own ideas.
First, there are Var and Val two ways of defining variables in Scala, the former defining a variable, the latter defining a non-variable, similar to the const in
Spark problem more than one Scala library found in the build path
There was an error building spark on Eclipse of window:
More than one Scala library found in the build path (d:/1win7/eclipse/plugins/org.scala-lang.scala-library_2.11.7. V20150622-112736-1fbce4612c.jar, G:/149/spark-assembly-1.5.2-hadoop2.6.0.jar). At least one have an incompatible version. Please update the project build path so it contai
Tags: Java project configuration except BSP Connection database Sync Sync service UTF8 two kindsLanguage Scala SQL Package Slick 3.2.0 MySQL Database Database Synchronization Program Error string ' \xf0\x9f\x87\xb5\xf0\x9f ... ' for ' content ' 1 This error is too much to see, emoji characters and utf-8 incompatible, utf8mp4 character set support emoji Source Library (provided by another company) changed the character set of the table, did not not
Recently, when processing data, you need to join the raw data with Redis data, in the process of reading Redis, encountered some problems, by the way to make a note, hoping for other students also helpful. During the experiment, it was not stressful to read Redis one at a time when the amount of data was 100,000 levels, but when the amount of data reached tens, the problem arose, even with the mappartitions of Spark. Therefore, consider using Redis's pipeline (if you have a better approach, plea
Rt.
Package Com.scalalearn.scala.main/** * Learn Scala 02 exercises */Object LEARNSCALA02 {//1. If a number is positive, its signum is 1; if it is negative, SIGNU
M is-1; if it is 0, then Signum is 0//write a function to calculate the value def execise1 (num:int): Int = {if (num > 0) 1 else if (num = = 0) 0 Else-1} 2. What is the value of an empty block expression. What is its type//value is (), the type is unit//3. It is pointed out that
Now, here are the steps to build your development environment:Because Scala is a language on the JVM, we first install the Java Runtime environment. Download and install JDK8 from Oracle official website. Note that Scala only needs to run the Java environment, that is, to install only: JRE, but in order to facilitate future Java development, we still install the Java development environment. After the insta
There are several zip-related functions in Scala, such as zip,zipall,zipped, Zipwithindex, and so on. We often see such functions in our code, and this article mainly introduces the differences and uses of these functions.1, the ZIP function will pass in two parameters in the corresponding position of the elements to form a pair array. If one of the parameter elements is longer, then the extra parameters are deleted. Look at the English introduction:R
(Bus). Only through horizontal expansion (scale out), that is, distribution expansion by increasing the computer server and then using the distributed computing technology to divide the computational task into discrete servers for processing; This is the core of big data technology.Predictably, we will face the future: distributed data, high concurrency processing, parallel computing, NoSQL and very large interactive complex network platform programming. As a veteran programmer, experienced fro
Scala list/sequence faq:how do I iterate over a Scala List (or more generally, a sequence) using the foreach method or for loop?There is a number of ways to iterate over a Scala List using the foreach method (which was available to Scala sequences like ,,,, List Array ArrayBuffer Vector Seq , etc.) for and comprehensio
Previous Article: Scala Tutorial: interaction with Java, everything is an object
This document is translated from the official Scala tutorial. to prevent misunderstanding, keep the original document for reference.
Due to space limitations, there are three articles.
Blog formats are not easy to adjust, interested friends can download PDF version: http://download.csdn.net/source/1742639
---
6Condition class a
1. JDK official website address: https://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html
Scala is based on Java and uses a large number of Java class libraries and variables. Therefore, you must install Java before using Scala.
Install JDK and select the installation path
Check whether the installation is successful
Open CMD and enter Java-version. If the Java version is
1. Download Scala 2.9.2
Since the latest Scala 2.10 stabilizer is not finished, it's best to download the latest Scala stable version: 2.9.2.Download Address: Http://www.scala-lang.org/downloads/distrib/files/scala-2.9.2.msiThe advantage of downloading the MSI version is that the environment variable is automatically
First, download Scala installation package
From the official Scala website address: http://www.scala-lang.org/download/Download Scala binary package, in 2.11.8 version For example two, installation
1. Move the downloaded binary package to the/usr/local directory and unzip the package
Tar zxvf scala-2.11.8.tgz
MV
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.