Scala learning notes, scala Learning

Source: Internet
Author: User

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 Object is called a Companion Object of a class ). The two can access each other's private members. Companion objects can be understood as static member functions of classes with the same name.
3. The Scala file name does not need to be the same as the class name. But it is best to be the same for convenient maintenance and programming.
4. When defining a variable, it must be modified with val or var:
var hw =new helloworld("Hi,my name is lming_08")

Scala will automatically identify the type as helloworld. Of course, you can also specify the type.
var hw:helloworld =new helloworld("Hi,my name is lming_08")

5. Define a method
scala> def max(x: Int, y: Int): Int = if (x < y) y else xmax: (Int,Int)Int
The Int value after the colon is the result type. If the defined method is recursive, The result type of the method must be explicitly specified. For a common method, the compiler can deduce the result type. Note: The parameter type must be explicitly specified. When the method body involves multiple statements, you need to use {} to enclose them.
6. Circular usage
def arrLoop(arr:Array[String])={    arr(0)="abc"    arr(1)="123"    arr(2)="ABC"    for(elem<- arr)      println(elem+", hello")  }  def arrLoop2(arr:Array[String])={    arr(0)="+abc"    arr(1)="+123"    arr(2)="+ABC"    arr.foreach(elem => println(elem))  }  def arrLoop3(arr:Array[String])={    arr(0)="-abc"    arr(1)="-123"    arr(2)="-ABC"    for(i <- 0 to arr.length -1){      println(arr(i))    }  }

7. array differs from List. Array is a sequence of variable objects. after instantiation, the length of Array cannot be changed, but the value of its elements can be changed. List is a sequence of immutable objects, more functional-oriented; Scala List and Java List (java. util. list) is also different. Scala List is unchangeable, while Java List is variable. More importantly, Scala List is more functional-oriented. Val oneTwoThree = List (1, 2, 3)

Not complete...


References: http://www.artima.com/scalazine/articles/steps.html

Github exercise code


Learning scala requires java Basics

It's best. It's okay. Both of them are based on jvm.

Scala's learning curve is steep, so it is not recommended that people without programming experience learn it.

For Study Notes

How to write Chinese notes

How to write Chinese notes

As the saying goes, "It's better to remember with ink", and "it's better to write your mind over a thousand times ". The teacher makes the class clearer in class. If the students do not remember it, they will forget it later. Note-taking is an extension of memory for future review and searching. The more advanced the learning, the more important it is to remember. Students take notes while attending lectures in the classroom. They can be in the best learning status of brainstorming, hands-on, and ears. They can suppress the "thoughts" and make their attention highly concentrated, improve efficiency, and deepen their impressions. Note Taking can also speed up writing and save time. Teachers should teach students to take Chinese notes from the upper grades of primary school. When I was a child, students learned to take Chinese notes, which laid the foundation for future Chinese learning and other subjects, formed self-learning ability, and formed good study habits, and can be used for life.

How do I take Chinese notes? Students should write their preview notes, class notes, and some Chinese homework together in one book, collectively referred to as "Chinese notes ". In this way, the complexity can be simplified, which not only reduces the Learning Burden of students, but also reduces the burden of teachers' correction. There are both checks on students' previewing, feedback on classroom teaching, and acceptance of basic knowledge. The teacher can correct the Chinese notes and receive the effect of "three in one fell swoop.

It is best to use a 16-open "course preparation notebook" in a Chinese notebook. Draw two straight lines on both sides of each page and divide them into three parts. One copy on the left is about two characters in width, which is used for project recording and serves as a Directory Index. the other copy on the right is about one inch in width and is used for remarks. This part is used flexibly by students, note some difficult questions, your own comments, feelings, and learning methods. The content of this part is inconsistent. the widest and most important one in the middle is, the learning content is recorded in this section.

After the preparation is complete, the next step is how to remember. You can take Chinese notes in three stages:

1. Preparations before class

Before learning a new course, students should preview the course, and record the content learned in the course and the problems they cannot solve in the middle and right parts of the Chinese notes respectively. The words and words that can be solved through the tool book are all completed at this time, which is one of the three parts of the Chinese notes.

2. Lecture Notes

This is the most important part in Chinese notes. In a Chinese class, students need to take notes while taking lectures, record the content of the new course in the middle column, and record the content that can be corrected due to inaccurate understanding in the preview in the remarks column on the right. At this time, there are two points to note: first, students can't talk about it. After the course, the students write the content they want to remember on the blackboard; second, the students cannot write down all the words the teacher says. On the basis of understanding, they should listen and think, sum up the key points, and generalize them into key sentences or words, then write it to the Chinese notes, as long as the meaning is correct. When starting the training, the teacher should say slowly what needs to be recorded, and repeat the long sentences and important points one or two times. Keywords, new words, Homophone Words, and easy-to-mix and easy-to-error words to be remembered. Teachers should blackboard writing to prevent students' mistakes.

3. consolidation after class

After a Chinese lesson, students need to take notes. The questions that have been solved in the text should be followed up, and the missing parts should be supplemented. It is best to remember them in summary, the good words and good sentences in the article can also be excerpted based on interest. After the course is organized and modified, the students' understanding of the content is deepened and their understanding is improved. The content to be recorded after class also includes some exercise questions after the course, such as the words to be copied, the words to be interpreted, the words to be interpreted, the meanings of the key sentences to be understood, and the brackets, sentences. In this way, the content of each lesson is concentrated on the Chinese notes, so that the knowledge can be easily classified for review and search; students can save the additional effort to write their homework, and the Chinese notes can be handed over as homework; when correcting Chinese notes, the teacher not only accepted the basic knowledge of the course, but also checked the students' preview and lectures. During the training process, teachers should focus on students, solicit Students' Opinions, constantly improve their practices, and do not insist on consistency in form and content. This can cultivate students' creative and divergent thinking abilities.

Chinese classroom learning and guiding strategies

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.