Home > other >  Scala learning notes (turn)
Scala learning notes (turn)

Time:09-28

Scala for realizing scaleable language as the original design of a language, the official, said it is the object - oriented language and functional language hybrid language, and scala and Java program can seamless splicing, because scala file compiled also become. Class files, and run on the JVM, however, I was more concerned with its scaleable (extensibility), a language how extensibility is? What is its scalability for language?

Personal humble opinion, believed that language scalability may include two aspects:

1, language itself scalability

2, the written language program scalability

For the first point, the scala mentioned in the introduction of some developer can use scala to define their own Domain Specific Language, I think, this may be reflected the extensibility of the scala Language itself, meaning that it can be processed as another potential can be used in the field of special Language (perhaps by adding certain models, or certain actions, etc.),

For the second point, touch the deepest is about to see the Tuple, once when doing a project, want a function can return to the two parameters, and had to redefine a JavaBean (inherited before its predecessor in order to keep the other return value), but this leads to the upper code is a mess, is to call the original BaseBean for a while, for a while and call the new Bean, if also can have a similar Java Tuple is convenient,

This paper will describe the three contents:

The Tuple - different types of data can be stored in an array

No static methods and properties in singleton objects in scala, all by the singleton object (singleton) to replace the

Trait in scala classes in the interface, but can have method body, and mixing in can be instantiated in the class, and don't need for packaging a class and subclass generation

Tuples array
Like Lists and tuples are immutable, but unlike Lists and tuples can contain the company types of elements. Thus whereas a list took a be a list [Int] or a list [String], a tuple could contain both an Int and a String at the same time. The tuples are very useful, for example, if you need to return multiple objects from a method, whereas in Java, you order, create a JavaBean - Like the class to hold the multiple return values, in Scala you can simple return a tuple.

Val pair=(99, "Luftballons")
Println (pair) _1)
Println (pair) _2)

CodePudding user response:

Study study study study study

CodePudding user response:

in the function, if as a parameter, if only to Tuple20.,,, a little dizzy

CodePudding user response:

refer to the second floor JackRui2008 response:
in the function, if as a parameter, if only to Tuple20.,,, a little dizzy

Case class to meet you, 200 are ok
  • Related