Scala's classic 81st: The construction of list in Scala is type constrained inversion, covariance, and the lower bound

Source: Internet
Author: User

:: Appends the object to the head of the list.

The head part of an existing list[subclass X] is placed in another object A, which is a subclass Y, and if both a object and the original list object inherit from the same parent class, the list is displayed as the list[parent class].

The parameters of the function are contravariant so that covariance cannot occur, so the nether is used to solve the problem. The object to which the:: Method returns is programmed as a list of upper bound object B.


interested friends please pay attention to DT Big Data Dream Factory public account: Dt_spark

Liaoliang Teacher Number: 18610086859

QQ Group: DT Big Data dream factory ①:462923555 DT Big Data dreamworks ②: 437123764 DT Big Data Dream Factory ③:418110145



Scala's classic 81st: The construction of list in Scala is type constrained inversion, covariance, and the lower bound

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.