The first chapter of Scala learning

Source: Internet
Author: User

Using Val,var to declare variables in Scala,

Scala writes the type of a variable or function behind a function or variable such as Var greet:string

You can put multiple values or variables together in Scala for example: Var greeting, age:string

Scala uses methods, rather than forcing type conversions, to convert between numeric types such as: 5.21.toInt get a, 99.toChar get ' C '

No operator + + in Scala with counter + = 1

Operators are allowed to be overloaded in Scala

There is no static method in Scala, but a class pair should have a companion object in Scala, like a static method in Java, for example, the bigint companion object of the BigInt class has a Probableprime method that generates the specified number of bits. Bigint.probableprime

Scala methods without parameters usually have no parentheses for example: "Hello". Distinct

If S is a string, in Scala s (i) is the string I string, and in Java to write S.charat (i)

BigInt ("1234567") is shorthand for bigint.apply ("1234567"), which produces a new object and does not use the Apply method of the common companion object in New,scala to build the object


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

The first chapter of Scala learning

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.