Scala basic Concept +ideRecommended: "Scala Programming"1 Basic ConceptsIn spark development, Scala is considered to be the best-compatible language for current and spark.
Scala run on a standard Java platform that can be used with Java seamless interaction.
I. Basics
1. VariablesVal identifier: Declares constants. For example, Val answer = 1.VaR flag: declares a variable;
Type inference: Scala deduce the type of a variable based on the expression of the initialization variable;
Val is encouraged;
Note: An error is reported if the variable is declared without initialization.
Explicit type: Scala variables or functions are always written after variables or
Because Scala has a more complete Eclipse IDE (Scala IDE for Eclipse), it's easy, fast, and convenient for Dev who doesn't want to migrate from Eclipse to the IEA platform. It is particularly important to compile and package the development of Scala applications under Eclipse. SBT is a build tool similar to MAVEN, which we will use to build the publishing program
Use of 1.Scala ReplInstall Scala and append the bin directory of the Scala installation directory to the PATH environment variable. In this case, you can enter Scala directly under CMD to enter REPLEnter REPL, and you can enter a valid expression in Scala after the command p
Scala Featured Tutorials-case class and pattern matching
Scala Featured Tutorials-case class and pattern matching (1): A simple Demo sample
Scala Featured Tutorials-case class and pattern matching (2): type of pattern (i)
Scala Featured Tutorials-case class and pattern matching (3): type of pattern (ii)
methods for traversing collections
1. Iterating through a collection with a foreach Loop
foreach receives a function as a parameter. The defined function should receive an element as an input parameter, and then do not return anything. The type of the input parameter should match the type in the collection. With the execution of foreach, it passes an element to your function every time, until the last element in the collection.
The most common use of foreach is output information:
The concepts of classes and methods in Scala are similar, and here are just some of the important concepts of Scala: 1.Public is the default access level for Scala and can be omitted. An important feature of the method parameters in 2.Scala is that they are all Val, not Var (the argument is Val is easier to articulate,
To create a string:
The most straightforward way to create a string is to write a method that:
var greeting = "Hello world!";
Or
var greeting:string = "Hello world!";
Whenever you encounter a string in code, the compiler creates a string object and its value in this example using: "Hello world!", but if you like, you can give the string, because here I have alternately shown in the declaration.
Object Test {
Val greeting:string = "Hello, world!"
def main (args:array[string]) {
printl
First lesson: Getting Started with ScalaThe great value of 1:scala2:scala basic function Getting started combat3:scala function Getting Started combatArray,map,tuple Combat in 4:scala5: Comprehensive case and spark source code analysisThe relationship between Scala and Java:One: They're all JVM-based, but Scala can inv
Knowledge Points: 1. Conditional expression if (x>0) 1 Else 0 Scala each expression has a type, if it is the same type, and if it is a mixed-type expression, the public superclass of any.if (x>0) 1 may not have output values, in Scala, each expression should have some value, introducing the Unit class, writing (). if (x>0) 1 is equivalent to if (x>0) 1 else () 2. Statement termination, if you write a long s
A systematic study of Scala has recently begun. In fact, I used Scala before, for example, when I was using Gatling's performance testing tool, I was exposed to Scala. Gatling itself is written in Scala, and the Gatling performance Test profile itself is a Scala class that i
The main contents of this section
Introduction to Scala I/O operations
Scala Writing Files
Scala Read files
Scala Network I/O
Introduction to Regular expressions
Scala regular-expression combat
1. Introduction to
ArrayLike an array of Java, it is also an immutable arrays, and since both Scala and Java are running in the JVM, both sides can call each other, so the bottom of the Scala array is actually a Java array.
Note: Accessing an array of elements using () instead of [] in Java
Scala>ValA =NewArray[string] (Ten) a:array[string] = Array (NULL,NULL,NULL,NUL
The first step is to build the Scala development environment and find tutorials on the web.declaring constants and variablesval foo = 0 //constant var bar = 0 //variable In Scala, it is more encouraged to declare using Val, which is the recommended constant. Most of the time do not need a semicolon, look at their own good ... Although it is a strongly static type of language, it does not write the type-t
1, Scala and Java have 7 numeric types: int, short, long, byte, float, double, Boolean 7 kinds, but in Scala, these 7 types of values are classes, in Java, the basic type, Java, Data types are divided into basic types and reference types, which are not differentiated in Scala.2. The type of a variable or function in Scala
A function is a set of statements that perform a task together. You can put your code in a separate function. How to divide your code between different functions, but logically, partitioning is usually to allow each function to perform a specific task.
Scala has functions and methods, and our terminology says that the methods and functions are interchangeable in small differences. The Scala approach is to h
"Editor's note" Although Java has won a lot of developers love, but compared to other modern programming languages, its syntax is indeed slightly lengthy. But with Java8, you can write code that is both readable and concise by using lambda expressions directly. The author Hussachai Puripunpinyo's software engineer, who analyzed the differences in performance and expression by comparing Java 8 and Scala, and discussed in depth the differences between t
In the first article in this series, "thinking by using recursion," the authors do not introduce Scala's syntax first, for two reasons: one is because too much of the grammatical details distract the reader, ignoring the basic concept, the basic idea; and the second is that Scala The syntax is very concise, and programmers with other language programming experience can easily read Scala code. Now we're goin
There are many similarities between Scala and Java, but there are many differences. This is primarily a Java developer's perspective, summarizing some of the thinking changes that are faced in the process of using Scala. Here is just a summary of the two languages in the development process of the different, will be updated after some switching in the development process is worth noting. The following is a
Summary: When it comes to dealing with large-scale data, R, Python, Scala, and Java basically meet your requirements.
There is a big data project, you know the problem area (problem domain), you know what infrastructure to use, and maybe even decide which framework to use to process all of this data, but one decision has been delayed: which language should I choose? (or perhaps more specifically, the question is, what language should I force all
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.