Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the function of Scala non-value type

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

In this issue, Xiaobian will bring you about the role of Scala non-value types. The article is rich in content and analyzed and described from a professional perspective. After reading this article, I hope you can gain something.

method type

The method type is represented internally as (Ts)U, which is a sequence of types (T1,..., Tn) n>=0, U is a (value or method) type. This type represents a named method whose parameters are of type T1,..., Tn, the type of return result is U.

The method type is right associative, and the way (Ts1)(Ts2)U is processed is (Ts1)(Ts2)U).

A special case is a method type with no parameters. It can be written in the form =>T. The parameterless method name expression is evaluated each time the name is referenced.

Method types do not exist as types of values. If a method name is referenced as a value, its type is automatically converted to the corresponding function type (§6.25).

Example 3.3.1 The following statement:

def a: Int

def b (x: Int): Boolean

def c (x: Int)(y: String, z: String): String

The following types are generated:

a: => Int

b: (Int) Boolean

c: (Int)(String, String) String

polymorphic method type

Polymorphic method types are represented internally as [tps]T,[tps] is the type parameter part [a1 >: L1 : Ln =0, T is a (value or method) type. This type represents an array with S1,..., Sn is a naming method for type parameters and produces results of type T, parameter types S1,..., Sn and lower bound L1,..., Ln and upper bound U1,..., Un consistent (§3.2.4).

Example 3.3.2 The following statement:

def empty[A]: List[A]

def union[A : Nothing : Nothing : L1 : Ln

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report