Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/scala/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Scala中C类型约束(其中)的等效项_Scala - Fatal编程技术网

Scala中C类型约束(其中)的等效项

Scala中C类型约束(其中)的等效项,scala,Scala,在C中,您可以定义一个方法 public T GetComponent<T>() where T : IComponent 表示T必须是i分量 如何在Scala中表达相同的内容?在Scala中,这称为a,因为您也可以使用C中不存在的约束。您可以这样定义它们: def getComponent[T <: IComponent] 在Scala中,这被称为a,因为您也可以有一个C中不存在的约束。您可以这样定义它们: def getComponent[T <: ICompon

在C中,您可以定义一个方法

public T GetComponent<T>() where T : IComponent
表示T必须是i分量


如何在Scala中表达相同的内容?

在Scala中,这称为a,因为您也可以使用C中不存在的约束。您可以这样定义它们:

def getComponent[T <: IComponent]

在Scala中,这被称为a,因为您也可以有一个C中不存在的约束。您可以这样定义它们:

def getComponent[T <: IComponent]