1. In Scala, the type of a variable or function is always written after the name of the variable or function. 2.scala does not differentiate between the base type and the reference type 3. Defining constants with Val, defining variables with var declared by Val will only generate getter, and VAR will generate setter,getter 4. The C + + I and I + + in Java do not work in Scala 5. parameterization: When you create an instance, you complete the "set" 6.a*b: The left operand is the caller of the method and can be written a.* (b) but 1: Twothree,:: The caller of the method is twothree,1 is an incoming parameter of the method, which can be written as Twothree.::(1) (the method ending with ': ' is called by its right operand and passed in the left operand to the other end of the other character.) 7. The method body is not preceded by an equal sign, but with curly braces, the result type of the method must be unit, if the method finally returns a string, but the result type is declared as unit, then the string is converted to unit and the original value is discarded. So in order to avoid errors, it is best to take the equals sign 8. The difference between a class and a singleton object is. The Singleton object has no arguments, and the class can, because the singleton object is not instantiated with the new keyword, so there is no chance to pass it to the instantiation parameter, and the singleton object will be initialized 9 the first time it is accessed. Any method can be an operator, whether it is an operator or a method depends on how you use it. If you write S.indexof (' O '), indexOf is not an operator, but if you write S indexOf ' o ', then indexOf is the operator because you use it as an operator notation. 10 that a member in the parent class is declared as Var, it is wrong to rewrite the subclass with Val because Var provides the Setter/getter method, and Val only provides the Getter method 11. The first action of each auxiliary constructor in Scala is to call the same constructor 12. Local functions can access parameters that contain their functions. 13. To make the function literal shorter: Go to type argument and omit parenthesis, underline as one or more placeholder 14. In Scala, accessing a field is slightly faster than calling a method, because the value of the field is budgeted at the time the class is initialized, and the method call is evaluated every time the call is made. However, the use of fields requires additional memory space. 15. You can omit empty parentheses when calling a method without parameters &NThe fields and methods in Bsp;16.scala belong to the same namespace, so you can use fields to override the parameterless method, so Scala prohibits defining fields and methods in the same class with the same name as different from Java (4 namespaces), Scala has only two namespaces, values (fields, method, the package also has a singleton object), type (class and trait name) 17.content mkstring "\ n": Format the content array as a string, where each array element occupies one row 18.any is a superclass of all other classes, Nothing is a subclass of all other classes 19. When declaring a function with a return statement, you must declare the type returned as:def A (): Int = {return} 20. If there are no parentheses in the class when declaring the parameterless method, then the call cannot be made with parentheses 21. If the pointer appears only once to the right of the parameter can be used _ such as: Def f (x = x * 3) equivalent to Def f (_ * 3) 22. Generic Type Match note list [String],map[char,int] cannot be matched because the match is occurring in the compilation, the list's generics are erased, causing the list to match successfully, but Array[int] can match the success
Scala Learning Notes