Scala Classic 41st: List inheritance system to implement insider and method operation source code disclosure

Source: Internet
Author: User

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

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.