Note: This study originates from: DT Big Data DreamWorks (public number: Dt_spark)1. Download the Scala installation package First:For subsequent spark Learning, we need to choose version:2.10.4Http://www.scala-lang.org/download/2.10.4.html2. After installation, choose the Scala IDE, one is the Eclipse Scala IDE, the other is Intellij ideaBecause of personal pref
Scala getting started-10 implicit conversions, implicit parameters, implicit classes, scala-10
So far, implicit conversion is the key and difficulty of scala ~
First, create a class named Implicit. scala.
Let's look at an example of an implicit parameter:
The implicit parameters are used in the above exampl
Scala: Pack, scala
Scala has the same purpose as a java package or a c ++ namespace. It can contribute content to multiple packages in the same file.
Use the full package name whenever possible. Avoid using scala, java, com, org, and so on to name nested packages. The concatenation package statement can limit the v
A, Scala is a compiled language, you can call Java code at will;B, Scala Functional programming language, in the Scala world, the function is a class citizen;
Functions can be passed as parameters, can be assigned to variables, and can be returned as return values
in Scala, there are nested functions, anonymou
First, the foregoing
The functions in Scala are still more important, so this article enumerates the functions that may be used in Scala and explains them in detail.
Second, the specific function
1, the definition of Scala function
def fun (A:int, b:int): unit = {
println (a+b)
}
Fun (1,1)
def fun1 (a:int, b:int) = A+b
printl N (fun1 (1,2))
No
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
[TOC]
Array fixed-length arraysIf you need an array of the same length, you can use the arrays in Scala. For example:val numsArray = new Array[Int] (30) //长度为30的整数数组,所有元素初始化为0val stringArrays = new Array [String] (30) //长度为30的字符串数组,所有元素初始化为nullval sHello = Array("Hello", "World") //长度为2的Array[String]类型是推断出来的,已提供初始值就不需要newsHello(0) = "Hello Tom",使用()而不是[]来访问元素In the JVM, Scala's array is implemented as a Java array. The array in the example is of
The victory and defeat of the military are not in the future, and the shame of the bag is the male-douniu fighting, fighting, fighting...
It has been some time since I learned and used scala. At first, I learned scala mainly to learn the spark ecosystem. But after learning some scala features, I was deeply impressed by scala
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
public number is Dt_spark, every day will have big data actual combat video release, please continue to study.Liaoliang DT Big Data dream factory Scala all videos, PPT and code in Baidu Cloud disk link:http://pan.baidu.com/share/home?uk=4013289088#category/type=0 Qq-pf-to=pcqq.groupLiaoliang "Scala Beginner's introductory classic video course" http://edu.51cto.com/lesson/id-66538.htmlLiaoliang "
Package Com.leegh.parameterization/*** @author Guohui Li*/Class PersonClass Student extends PersonClass C[+t] (Val args:t)Trait Friend[-t] {def makefriend (Somebody:t)}Object Variance {def makefriendwithyou (S:student, f:friend[student]) {f.makefriend (s)}def main (args:array[string]): Unit = {Val Value:c[person] = new C[student] (new Student)}}Report:This blog description:1. Organize your ideas and improve yourself.2. Be educated in Liaoliang teacher, what to gain, so recommend.3. Blog focus on
In the first two sections, we learned about Scala's objects and associated objects, both of which are used to mean the static members of Java. There are no static fields and static methods in Scala. A static member destroys the complete object-oriented model that Scala supports. However, it is possible to implement class-level operations on Scala through the asso
Package Com.leegh.parameterization/*** @author Guohui Li*/Class Pair[t def bigger = if (First.compareto (second) > 0) First Else second}Class Pair_lower_bound[t] (Val first:t, Val second:t) {def Replacefirst[r;: T] (newfirst:r) = new Pair_lower_bound[r] (Newfirst, second)}Object Type_variables_bounds {def main (args:array[string]): Unit = {Val pair = new pair ("Spark", "Hadoop")println (Pair.bigger)}}Report:This blog description:1. Organize your ideas and improve yourself.2. Be educated in Liaol
First, prefaceThe Scala program uses Unicode's BMP character set (Wiki:bmp character set), which is not currently supported by the Unicode supplement character set. This chapter defines Scala's syntactic analysis from Scala models and XML models. If not specifically mentioned, the default refers to the Scala model and specifies that the characters are ASCII \u000
Scala code in one day (7) and scala code in one dayScala code in one day (7)To better control spark, I recently studied scala language features, mainly reading "quick learning scala" and writing down some codes that I think are useful.
Package examplesclass Angela {// package visibility This specifies that this method
Scala code in one day (9) and scala code in one dayScala code in one day (9)To better control spark, I recently studied scala language features, mainly reading "quick learning scala" and writing down some codes that I think are useful.
Package examplesimport scala. io. sour
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
Package Com.leegh.parameterization/*** @author Guohui Li*/Object Type_contraints {def main (args:array[string]): Unit = {def Rocky[t] (i:t) (implicit ev:t println ("Life is too short,you need spark!")}Rocky ("Spark")}}Report:This blog description:1. Organize your ideas and improve yourself.2. Be educated in Liaoliang teacher, what to gain, so recommend.3. Blog focus on practice, superfluous words are not much to say, are doing technology.4. Information from DT Big Data Dream Factory public accou
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.