First, Scala is the combination of functional programming and object-oriented programming language, what are the characteristics of these two programming? A: Functional programming excels at numerical calculations, and object-oriented programming is particularly well suited for large engineering or project organizations, and for team collaboration.Second, Scala the characteristicsScala elegant structure, so
impossible to give full play to the characteristics of functional programming, because the lack of generics, and the go language that the simple is because there is no class module generic concepts.Keith Morrow For example: If you want to implement a simple map function, using the imperative approach (using loops instead of recursion), you must force the forgetting of type safety (such as using an empty interface), or re-implement the map function once for each type. Go does not support functio
On this page, we'll cover the basics of Scala.
Try Scala in the browser
You can run Scala from the Scalafiddle in the browser.
Open Https://scalafiddle.io
In the left pane, pasteprintln("Hello, world!")
Click the "Run" button. The output is displayed in the right pane.
This is a simple, 0-setting way to test
Class level for 1.ScalaThe top of the class in Scala is any class that inherits any classes, and any includes the following common methods:Final def == =(That:any): Boolean def equals (That:any): Boolean def hashcode:int def tostring:string2 operator overloads, one Equals method, one Hashcode method and one tostring method.Root class any has two sub-classes: Anyval and AnyrefAnyval is the parent of a value type, and Anyref is the parent class of the r
Since I have been using idea to develop a Java project, Scala can now also use idea development: http://www.jetbrains.com/idea/Community Edition free and Ultimate Edition free 30-day trial all support Scala development, I use the Ultimate EditionWhen we download idea after installing and booting, we need to install a Scala Plugin, the following steps:The followin
The Github:https://github.com/scala/scala-tool-support project collects the configuration that the editor supports for Scala.1. The following Scala code is to get the vim configuration under Scala-tool-support.The Code of the blog shows that there is a pit, can be viewed her
coin also has another aspect, go is because it is imperative language, it is impossible to give full play to the characteristics of functional programming, because the lack of generics, and the go language that the simple is because there is no class module generic concepts.Keith Morrow For example: If you want to implement a simple map function, using the imperative approach (using loops instead of recursion), you must force the forgetting of type safety (such as using an empty interface), or
2, Scala simple example
Reference Tutorial: HTTPS://YQ.ALIYUN.COM/TOPIC/69 2.1 Interactive Programming
Spark-shell is spark interactive operating mode, provides interactive programming, side-knocking code side execution, do not need to create program source files, convenient debugging procedures, conducive to rapid learning spark.
[Root@node1 spark-2.2.0]# Bin/spark-shell Using Spark ' s default log4j profile:org/apache/spark/
Log4j-defaults.properti
Scala
is a object-oriented, statically-typed and functional programming language for the JVM. The strength of Scala lies in it's powerful syntax which allows to write readable, manageable code which are short and conc Ise–and It comes with great support for common design pattern (i.e. a special keyword for implementing the Singleton des IGN pattern).
There is plenty of good tutorials and introductions for l
must be set. The installation path is used to determine which several nodes Spark runs. The jar name will enable Spark to automatically transmit jar files to slave nodes.This program file relies on Spark APIs, so we must have an sbt configuration file to describe the dependencies between the program and Spark. The following is the configuration file simple. sbt:
name := "Simple Project"version := "1.0"scalaVersion := "2.9.3"libraryDependencies += "org.spark-project" %% "spark-core" % "0.7.3"res
Sublime3 Compile run Scala program
Using Sublime3 plus repl to invoke the command line, it is still convenient to run some code snippets. But direct compilation runs Scala programs, you need to add some settings.
1. Configuration:
Select Tools->build system->new build system and replace with:
{"cmd": ["D:\\scala\\bin\\scala.bat", "$file"]}
Save file:scala.
Learn Scala together with Lian le-advanced type, scala-type
Welcome to join Scala discussion QQ Group 212859367, and join!
Singleton type Example:
class Document{ def setTitile(title: String) = {...; this} def setAuthor(author: String) = {...; this} ...}val atticle.setTitle("whatever floats your boat").setAuthor("lianle")
If the above classes have child
Scala learning notes, scala Learning
The notes are complex!
1. The Singleton objects in Scala are decorated with objects, similar to static classes in C ++. When calling its internal functions, you can call them directly using the object name. You cannot apply for a new function!
2. A file can define classes and Singleton objects with the same name. A singleton O
In Java, variable types fall into two main categories: primitive types and reference types. Although the auto-boxing and auto-unpacking mechanisms have been introduced after JDK1.5, we have greatly reduced our entanglement between the direct and reference types, but there are still some issues that we have to consider. For example, I encountered a problem with the base type and the default value of its wrapper type, such as generics can only use reference types, such as by default the value of t
Scala is famous recently, but it is really so good. What I see is nothing. Scala's fame masks its shortcomings, so many people do not see its shortcomings. Although it is a functional programming language, it gives me the overall feeling of confusion and inconsistency, to be different, do you have to be different from other languages to show your excellence? You know, Java has been tested for more than 20 years. Isn't it worth learning from? Are you s
We talked about getting started with Scala, but after all, it's not like scripting language, and Scala is talking about replacing Java, so we'll see how he grabs the Java position.A common editor for Scala, see below:
Eclipse (using one of the shoddy and unstable Scala plugins)
Emacs
IntelliJ (basicall
In this Martin and two other pattern matching experts ' papers, there are several ways to implement pattern matching, and Scala chooses which way to implement it.Http://lampwww.epfl.ch/~emir/written/MatchingObjectsWithPatterns-TR.pdfI quoted some of the descriptions inside.In object-oriented programs, data is organized into class-level classesThe problem with object-oriented language in pattern matching is how to detect this level from the outside.The
The main contents of this article are as follows:
Variables and invariants
Functions and procedures
Parameters of the function
Semicolon
1. Variables and invariants 1.1. VariablesScala's variables are divided into two types, Var and val. var, or variable, is similar to the variables we touch in other languages such as Java, and Val, is value, similar to the non-assignable constants we use in other languages, or the final variable.Why this difference, this is because in
Scala briefly -- class and object, scalaClass
In scala, classes are not declared as public. The source file can contain multiple classes, all of which have common visibility. The getter and setter methods are provided for each field, which are called Field Names and field name_, respectively, and can be customized. Note: 1) if the field is private, getter and setter are also private. 2) if the field is val
language of the human learning function programming is difficult, go is a small and easy to learn language, of course, because it is closer to C and Python.
Of course the coin also has another aspect, go is because it is imperative language, it is impossible to give full play to the characteristics of functional programming, because the lack of generics, and the go language that the simple is because there is no class module generic concepts.
Keith Morrow For example: If you want to implement
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.