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
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
An expression
Scala> 1 + 1
res0:int = 2
value
You can assign the result of an expression to a variable (val) by name.
scala> val two = 1 + 1
two:int = 2
variable
If you need to modify the binding of this name and result, you can choose to use Var.
scala> var name = "Steve"
name:java.lang.String = Steve
scala> name
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
NothingNothing is a subclass of all types, and is also a subclass of NULL. Nothing has objects, but can be used to define types. For example, if a method throws an exception, the return value type of the exception is nothing (although it is not returned).def get(index:Int):Int = { if0thrownew Exception(...) else ....}If the statement is an expression with a return value, there must be a return value type, if x NullNull is a subclass of all Anyref, in Scala's type system, Anyref is a subcla
it's so ....Come back at night suddenly saw into the huge manuscript, can't help to the three ye, and then nothing did 23 o'clock ... 88th: Scala uses the for expression to implement map, FLATMAP, filterGoal:For expression Implementation Map/flatmap/filterGains:Map/flatmap/filter is a generic typeMORE:。。。。。。------------------------------------------------------------------------------------information from DT Big Data Dream Factory public account:Dt_s
One of the core features of functional programming is to pass functions as parameters to functions, to define functions inside functions, and so on.1, hands-on Scala high-order functionsDeclares a list collection instance:
The package that contains the list collection is already pre-defined and automatically imported, so there is no need to import the package here, and this is where the list instantiation object is used, which is actually the App
This is a Scala by Example from the official website.The example of how Scala is used in more detail after tutorial1.Programing with Actors and Message2.Expressions and Simple Functions3.first-class Functions4.Class and Objects5.Case Classes and Pattern Matching6.Generic Types and Methods7.Lists8.for-comprehensions9.Mutable State10.Computing with Streams11.Lazy Values12.Implicit Parameters and Conversions13
Basic content1. Array definitionsDefinition of fixed length, variable array, element addition, deletion, sorting, summation and other common operationsImport Scala.collection.mutable.ArrayBufferimport scala.math.bigdecimal.roundingmode/** * @author Xwolf * @date 2017-04-09 18:23 * @since 1.8 */object Collection {def main (arg:array[string]): Unit ={Multiplearray ()}/** * Array Creation */private def create (): unit={val a = new array[string] (1) A (0) = "Hello" println (A.tobuffer) Val A b =a
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.