Scala Classic 41st: List inheritance system to implement insider and method operation source code disclosure
Package Com.parllay.scala.dataset
/**
* Created by Richard on 15-7-25.
* 41st: List inheritance system to implement insider and method operation source code disclosure
*/
Object List_interal {
def main (args:array[string]) {
/**
* List: Inheritance system:
* List has two subcategories of Nil,::, they all achieved
* Override Def HEAD:B = HD
Override def tail:list[b] = TL
Override Def Isempty:boolean = False
These methods. The list is immutable, so it is secure in multiple threads.
In addition, its access time is O (n)
List is sealed abstract: This has two functions:
The modified Trait,class can only be inherited in the current file.
The purpose of the sealed modification is to tell the Scala compiler to let Scala know all the cases of the case when checking for pattern matching.
Scala will be able to check at compile time to see if the code you're writing is missing a case or not, reducing programming errors.
*/
Val List:list[int] = List (1, 3, 4, 5, 6)
}
}
Scala Classic 41st: List inheritance system to implement insider and method operation source code disclosure